|
LRAUV
revA
|
Implementation of a DataElement as a "UniversalDataElement". More...
#include <UniversalDataElement.h>


Public Member Functions | |
| UniversalDataElement (const UniversalURI &name, const DataValue *dataValue) | |
| Constructor for a universal DataElement. More... | |
| virtual | ~UniversalDataElement () |
| Destructor. More... | |
| virtual DataValue * | getDataValue (void) const |
| Implements the pure virtual from DataElement. More... | |
| virtual float | getAccuracy (const Unit &unit) const throw ( UninitializedException ) |
| Get the current DataElement accuracy. More... | |
| virtual float | getWrittenAccuracy (const Unit &unit) const |
| Get the last written DataElement accuracy. More... | |
| virtual bool | isOrphaned (void) const |
| Implements the UniversalDataElement's sense of "orphaned." A UniversalDataElement is orphaned if it has no DataElements registered to it. More... | |
| void | addElement (DataElement &element) |
| Adds the given DataElement to the list of participants in this Universal. More... | |
| virtual bool | isUniversal () const |
| void | notifyChangeDone (Component *notifier) |
| Causes the universal to be recalculated, if a change is pending. More... | |
| void | notifyChangeDone (DataWriter *notifier) |
| void | recalculate (void) |
| Reevaluate all participants and choose a new best solution. More... | |
| DataElement * | getBestElement (DataAccessor::RequestStrategy strategy=DataAccessor::MIN_ERROR) const |
| virtual bool | wasTouchedSinceLastRun (const Component *component) |
| Returns true if the value was touched since the last run of the indicated component. More... | |
| virtual const Timestamp & | getTimestamp () const |
| Returns the timestamp of last write. More... | |
| bool | isDataRequested (DataElement *element) |
| Returns true if one of the registered readers is requesting data and the indicated element is intended to provide the data. More... | |
| bool | isAnyDataRequested () |
| Returns true if one of the registered readers is requesting data. More... | |
Public Member Functions inherited from DataElement | |
| virtual | ~DataElement () |
| Destructor. More... | |
| DataReader * | findReader (const ElementURI &uri) |
| Returns the DataReader associated with this DataElement and the specified ElementURI. More... | |
| DataWriter * | findWriter (const ElementURI &uri) |
| Returns the DataWriter associated with this DataElement and the specified ElementURI. More... | |
| const ElementURI & | getUri (void) const |
| Get the full ElementURI for the DataElement. More... | |
| virtual bool | isUnavailable (void) const |
| Is the element "unavailable". More... | |
| virtual bool | isInvalid (void) const |
| Is the element "invalid". More... | |
| virtual bool | isOwnersFailed (void) const |
| bool | setUnavailable (bool unavailable, DataWriter *notifier) |
| Set the element's unavailable flag. More... | |
| bool | setUnavailable (bool unavailable, Component *notifier) |
| bool | setInvalid (bool invalid, DataWriter *notifier) |
| Set the element's invalid flag. More... | |
| bool | setInvalid (bool invalid, Component *notifier) |
| virtual void | setTimestamp (const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Sets the timestamp of last write Used if a more acurate timestamp is available. More... | |
| virtual bool | isOwnersActive (void) const |
| virtual bool | isActivatable (void) const |
| Indicates if the element is capable of being "active". More... | |
| virtual bool | isActive (void) const |
| Indicates if the element is "active". More... | |
| bool | isBest (DataAccessor::RequestStrategy strategy=DataAccessor::MIN_ERROR) const |
| Indicates if the element is the "best" of a set of measurements that feed into a universal. More... | |
| const Unit * | getUnit (void) const |
| Returns the Unit associated with this data element or NULL if no Unit is associated. More... | |
| void | registerUniversal (UniversalDataElement *abstract) |
| Indicates this DataElement should participate in the selection process for the given Universal. More... | |
| UniversalDataElement * | getUniversal (void) const |
| Returns the universal data element registered to this data element. More... | |
| void | registerReader (DataReader *reader) |
| Add the given DataReader to the list of readers for this DataElement. More... | |
| void | unregisterReader (DataReader *reader) |
| Remove the given DataReader from the list of reader for this DataElement. More... | |
| unsigned int | readerCount () const |
| The number of readers currently registered to this DataElement. More... | |
| bool | hasReaders (void) const |
| Does this DataElement have any readers? More... | |
| bool | isDataRequested () |
| Returns true if one of the registered readers is requesting data. More... | |
| bool | isImplemented () |
| Returns true if there is a non-failed "implementor" reader of this element. More... | |
| void | registerWriter (DataWriter *writer) |
| Add the given writer to the list of registered writers for this DataElement. More... | |
| void | unregisterWriter (DataWriter *writer) |
| Remove the given writer from the list of registered writers for this DataElement. More... | |
| unsigned int | writerCount () const |
| Number of writers registered to this DataElement. More... | |
| bool | hasWriters (void) const |
| Does this DataElement have any writers? More... | |
| virtual void | registerRead (DataReader &reader) |
| virtual void | registerWrite (DataWriter &writer, bool changed) |
| void | registerChangePending (DataWriter *writer) |
| void | registerChangeDone (Component *notifier) |
| void | registerChangeDone (void) |
| virtual bool | setAccuracy (DataWriter &writer, const Unit &unit, const float accuracy) |
| Set just the accuracy. More... | |
| virtual const Unit * | getBaseUnit () |
| The base unit that all writers and readers must use when accessing this value. More... | |
| virtual size_t | getTypeSize () |
| The base size that all writers must specify. More... | |
| float | getPower () |
| Power used by the component that owns this element. More... | |
| float | getError () |
| Error in measurements. More... | |
| float | getLatency () |
| Latency involved in requesting a measurement. More... | |
| float | getFrequency () |
| Frequency of measurements possible. More... | |
| void | setPower (float power) |
| Power used by the component that owns this element. More... | |
| void | setLatency (float latency) |
| Latency involved in requesting a measurement. More... | |
| void | setFrequency (float frequency) |
| Frequency of measurements possible. More... | |
| virtual bool | get (DataReader &reader, const Unit &unit, bool &readTo) throw ( UninitializedException ) |
| virtual bool | get (DataReader &reader, const Unit &unit, unsigned char &readTo) throw ( UninitializedException ) |
| virtual bool | get (DataReader &reader, const Unit &unit, double &readTo) throw ( UninitializedException ) |
| virtual bool | get (DataReader &reader, const Unit &unit, float &readTo) throw ( UninitializedException ) |
| virtual bool | get (DataReader &reader, const Unit &unit, int &readTo) throw ( UninitializedException ) |
| virtual bool | get (DataReader &reader, DataValue &readTo) throw ( UninitializedException ) |
| virtual const double | asDouble (DataReader &reader, const Unit &unit) throw ( UninitializedException ) |
| virtual const int | asInt (DataReader &reader, const Unit &unit) throw ( UninitializedException ) |
| virtual const Str | asString (DataReader &reader, const Unit &unit) throw ( UninitializedException ) |
| virtual bool | set (DataWriter &writer, const Unit &unit, const bool value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | set (DataWriter &writer, const Unit &unit, const unsigned char value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | set (DataWriter &writer, const Unit &unit, const double value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | set (DataWriter &writer, const Unit &unit, const float value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | set (DataWriter &writer, const Unit &unit, const int value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | set (DataWriter &writer, const DataValue &value, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set functions set int value. More... | |
| virtual bool | setWithAccuracy (DataWriter &writer, const Unit &unit, const bool value, const float accuracy, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set w/ Accuracy functions. More... | |
| virtual bool | setWithAccuracy (DataWriter &writer, const Unit &unit, const unsigned char value, const float accuracy, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set w/ Accuracy functions. More... | |
| virtual bool | setWithAccuracy (DataWriter &writer, const Unit &unit, const double value, const float accuracy, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set w/ Accuracy functions. More... | |
| virtual bool | setWithAccuracy (DataWriter &writer, const Unit &unit, const int value, const float accuracy, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set w/ Accuracy functions. More... | |
| virtual bool | setWithAccuracy (DataWriter &writer, const DataValue &value, const float accuracy, const Timestamp ×tamp=Timestamp::NOT_SET_TIME) |
| Set w/ Accuracy functions. More... | |
Protected Member Functions | |
| virtual float | setAccuracy (const Unit &unit, float accuracy) |
| Protected function. More... | |
| virtual void | setDataValue (DataValue *dataValue) |
| virtual float | getBaseAccuracy () const |
| Returns the accuracy in base, unscaled SI units. More... | |
Protected Member Functions inherited from DataElement | |
| DataElement (const ElementURI &name, const Unit *baseUnit, size_t typeSize) | |
| Protected constructor for base class. More... | |
| bool | setWrittenAccuracy () |
| Called before set commands to update the written accuracy Returns true if the written accuracy has changed. More... | |
| virtual void | setBaseUnit (const Unit *baseUnit) |
| virtual void | setTypeSize (const size_t typeSize) |
Protected Attributes | |
| DataElement * | bestElement_ |
| The current "best" DataElement (minError and enabled). More... | |
| DataElement * | minPowerElement_ |
| The current "minPower" DataElement. More... | |
| DataElement * | minErrorElement_ |
| The current "minError" DataElement. More... | |
| DataElement * | minLatencyElement_ |
| The current "minLatency" DataElement. More... | |
| DataElement * | maxFrequencyElement_ |
| The current "maxFrequency" DataElement. More... | |
| float | accuracy_ |
| The defaultValue_ to use if there if the Universal can't find a "best value". More... | |
| DataElementList | elementList_ |
| List of participating DataElements. More... | |
Protected Attributes inherited from DataElement | |
| ElementURI | name_ |
| The DataElement ElementURI. More... | |
| UniversalDataElement * | universal_ |
| Queue of UniversalElements which this DataElement "participates in". More... | |
| DataWriter * | notifier_ |
| The data writer responsable for notifying this element's Universal data element that a change is pending. More... | |
| FlexArray< DataWriter * > | writers_ |
| List of all registered DataWriters. More... | |
| FlexArray< DataReader * > | readers_ |
| List of all registered DataReaders. More... | |
| bool | unavailable_ |
| The "unavailable" flag is actually a simple boolean which is set by the user or by the DataElement itself. More... | |
| bool | invalid_ |
| The "invalid" flag is actually a simple boolean which is set by the user or by the DataElement itself. More... | |
| bool | wasOrphaned_ |
| Indicates that the element was previously orphaned. More... | |
| Mutex | mutex_ |
| Mutex for thread-safing an instance of DataElement. More... | |
| float | writtenAccuracy_ |
| Accuracy of last written value. More... | |
| Timestamp | timestamp_ |
| Timestamp of last write. More... | |
| bool | hasBeenSet_ |
| Flag – false until the first call to set done. More... | |
| const Unit * | baseUnit_ |
| The base unit that all writers and readers must use when accessing this value. More... | |
| size_t | typeSize_ |
| The base size that all writers must specify. More... | |
| float | power_ |
| Power used by the component that owns this element. More... | |
| float | latency_ |
| Latency involved in requesting a measurement. More... | |
| float | frequency_ |
| Frequency of measurements possible. More... | |
Private Member Functions | |
| UniversalDataElement (const UniversalDataElement &old) | |
Additional Inherited Members | |
Static Public Attributes inherited from DataElement | |
| static const float | NO_ACCURACY = 3.25e30 |
| Defines an accuracy quantity which means "no accuracy specified" typically means "don't use" i.e. More... | |
Implementation of a DataElement as a "UniversalDataElement".
Universal DataElements essentially contain a list of DataElements with the same UniversalURI name. When a DataValue is requested, the DataValue from the "best" DataElement is returned.
The determination of "best" is done whenever a DataElement changes in a significnat way, such as changing its accuracy, its failed state, or its orphaned state.
| UniversalDataElement::UniversalDataElement | ( | const UniversalURI & | name, |
| const DataValue * | dataValue | ||
| ) |
Constructor for a universal DataElement.
| name | The UniversalURI for this universal. |
| dataValue | Initial dataValue used to define dataType & size, etc. |
|
virtual |
Destructor.
|
private |
| void UniversalDataElement::addElement | ( | DataElement & | element | ) |
Adds the given DataElement to the list of participants in this Universal.
| element | The DataElement which is now checked for this Universal. |
References elementList_, DataElement::mutex_, and FlexArray< T >::push().
Referenced by Component::newUniversalBlobWriter(), Slate::NewUniversalWriter(), and Component::newUniversalWriter().
|
virtual | ||||||||||||||
Get the current DataElement accuracy.
Implements the pure virtual from DataElement.
Implements DataElement.
|
inlineprotectedvirtual |
| DataElement * UniversalDataElement::getBestElement | ( | DataAccessor::RequestStrategy | strategy = DataAccessor::MIN_ERROR | ) | const |
References bestElement_.
Referenced by DataElement::isBest().
|
virtual |
Implements the pure virtual from DataElement.
Implements DataElement.
References bestElement_, DataElement::getDataValue(), and DataElement::isInvalid().
|
virtual |
Returns the timestamp of last write.
Reimplemented from DataElement.
References bestElement_, DataElement::getTimestamp(), and Timestamp::NOT_SET_TIME.
|
virtual |
Get the last written DataElement accuracy.
Overrides the virtual from DataElement.
Reimplemented from DataElement.
References bestElement_, DataElement::getWrittenAccuracy(), DataElement::isInvalid(), and DataElement::NO_ACCURACY.
| bool UniversalDataElement::isAnyDataRequested | ( | ) |
Returns true if one of the registered readers is requesting data.
References DataReader::getRequestStrategy(), DataAccessor::NO_STRATEGY, DataElement::readers_, and FlexArrayBase::size().
Referenced by UniversalDataWriter::isAnyDataRequested().
| bool UniversalDataElement::isDataRequested | ( | DataElement * | element | ) |
Returns true if one of the registered readers is requesting data and the indicated element is intended to provide the data.
References DataAccessor::ALL_DEVICES, DataReader::getRequestStrategy(), DataAccessor::MAX_FREQUENCY, maxFrequencyElement_, DataAccessor::MIN_ERROR, DataAccessor::MIN_LATENCY, DataAccessor::MIN_POWER, minErrorElement_, minLatencyElement_, minPowerElement_, DataAccessor::NO_STRATEGY, DataElement::readers_, and FlexArrayBase::size().
Referenced by DataElement::isDataRequested().
|
virtual |
Implements the UniversalDataElement's sense of "orphaned." A UniversalDataElement is orphaned if it has no DataElements registered to it.
It is not orphaned (it is failed) if it's unable to select a DataElement.
Reimplemented from DataElement.
References elementList_, and FlexArrayBase::isEmpty().
|
inlinevirtual |
Reimplemented from DataElement.
| void UniversalDataElement::notifyChangeDone | ( | Component * | notifier | ) |
Causes the universal to be recalculated, if a change is pending.
References bestElement_, EventEntry::DATA_STATE_CHANGE_SET_BEST, Component::getLogger(), Logger::log(), and recalculate().
Referenced by Component::newUniversalBlobWriter(), Slate::NewUniversalWriter(), Component::newUniversalWriter(), and DataElement::registerChangeDone().
| void UniversalDataElement::notifyChangeDone | ( | DataWriter * | notifier | ) |
| void UniversalDataElement::recalculate | ( | void | ) |
Reevaluate all participants and choose a new best solution.
The heart of the Universal, go through all registered DataElements, find the best (most accurate).
References accuracy_, bestElement_, elementList_, DataElement::getBaseAccuracy(), DataElement::getError(), DataElement::getFrequency(), DataElement::getLatency(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), DataElement::getPower(), DataElement::hasBeenSet_, DataElement::invalid_, DataElement::isActivatable(), DataElement::isActive(), DataElement::isInvalid(), maxFrequencyElement_, minErrorElement_, minLatencyElement_, minPowerElement_, DataElement::mutex_, and DataElement::NO_ACCURACY.
Referenced by notifyChangeDone(), and Component::setRunState().
|
protectedvirtual |
Protected function.
Shouldn't be able to set the Universal's accuracy. Does nothing. Returns current value for accuracy.
Implements DataElement.
|
inlineprotectedvirtual |
Implements DataElement.
|
virtual |
Returns true if the value was touched since the last run of the indicated component.
Reimplemented from DataElement.
References bestElement_, and DataElement::wasTouchedSinceLastRun().
|
protected |
The defaultValue_ to use if there if the Universal can't find a "best value".
The current Universal accuracy. Set either to the accuracy of the current "best value" or to DataElement::NoAccuracy_s if the Universal is failed.
Referenced by getBaseAccuracy(), and recalculate().
|
protected |
The current "best" DataElement (minError and enabled).
Referenced by getBestElement(), getDataValue(), getTimestamp(), getWrittenAccuracy(), notifyChangeDone(), recalculate(), and wasTouchedSinceLastRun().
|
protected |
List of participating DataElements.
Referenced by addElement(), isOrphaned(), and recalculate().
|
protected |
The current "maxFrequency" DataElement.
Referenced by isDataRequested(), and recalculate().
|
protected |
The current "minError" DataElement.
Referenced by isDataRequested(), and recalculate().
|
protected |
The current "minLatency" DataElement.
Referenced by isDataRequested(), and recalculate().
|
protected |
The current "minPower" DataElement.
Referenced by isDataRequested(), and recalculate().