cisst-saw
|
#include <mtsStateTable.h>
Classes | |
class | Accessor |
class | AccessorBase |
class | DataCollectionInfo |
class | IndexRange |
Public Member Functions | |
mtsStateTable (size_t size, const std::string &name) | |
~mtsStateTable () | |
bool | SetSize (const size_t size) |
mtsStateIndex | GetIndexReader (void) const |
void | GetIndexReader (mtsStateIndex &timeIndex) const |
mtsStateIndex | GetIndexDelayed (void) const |
size_t | SetDelay (size_t newDelay) |
bool | ValidateReadIndex (const mtsStateIndex &timeIndex) const |
const bool & | AutomaticAdvance (void) const |
void | SetAutomaticAdvance (bool automaticAdvance) |
int | GetStateVectorID (const std::string &dataName) const |
template<class _elementType > | |
mtsStateDataId | NewElement (const std::string &name="", _elementType *element=0) |
template<class _elementType > | |
void | AddData (_elementType &element, const std::string &name="") |
template<class _elementType > | |
_elementType * | GetStateDataElement (mtsStateDataId id) const |
mtsGenericObject * | GetStateVectorElement (size_t id) const |
template<class _elementType > | |
mtsStateTable::AccessorBase * | GetAccessor (const _elementType &element) const |
mtsStateTable::AccessorBase * | GetAccessor (const std::string &name) const |
mtsStateTable::AccessorBase * | GetAccessor (const char *name) const |
mtsStateTable::AccessorBase * | GetAccessor (const size_t id) const |
mtsStateIndex | GetIndexWriter (void) const |
void | Start (void) |
void | StartIfAutomatic (void) |
void | Advance (void) |
void | AdvanceIfAutomatic (void) |
bool | ReplayAdvance (void) |
void | Cleanup (void) |
double | GetTic (void) const |
double | GetToc (void) const |
size_t | GetHistoryLength (void) const |
size_t | GetNumberOfElements (void) const |
double | GetAveragePeriod (void) const |
void | ToStream (std::ostream &out) const |
void | Debug (std::ostream &out, unsigned int *listColumn, unsigned int number) const |
void | CSVWrite (std::ostream &out, bool nonZeroOnly=false) |
void | CSVWrite (std::ostream &out, unsigned int *listColumn, unsigned int number, bool nonZeroOnly=false) |
void | CSVWrite (std::ostream &out, mtsGenericObject **listColumn, unsigned int number, bool nonZeroOnly=false) |
const std::string & | GetName (void) const |
void | DataCollectionEventTriggeringRatio (const mtsDouble &eventTriggeringRatio) |
template<class _elementType > | |
mtsStateTable::AccessorBase * | GetAccessor (const _elementType &element) const |
void | DataCollectionStart (const mtsDouble &delay) |
void | DataCollectionStop (const mtsDouble &delay) |
![]() | |
virtual | ~cmnGenericObject (void) |
virtual const cmnClassServicesBase * | Services (void) const =0 |
bool | ReconstructFrom (const cmnGenericObject &other) |
std::string | ToString (void) const |
virtual void | ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const |
virtual bool | FromStreamRaw (std::istream &inputStream, const char delimiter= ' ') |
virtual void | SerializeRaw (std::ostream &outputStream) const |
virtual void | DeSerializeRaw (std::istream &inputStream) |
virtual cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
virtual size_t | ScalarNumber (void) const |
virtual bool | ScalarNumberIsFixed (void) const |
virtual double | Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range) |
virtual std::string | ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const |
Public Attributes | |
mtsDouble | Tic |
mtsDouble | Toc |
mtsDouble | Period |
mtsIntervalStatistics | PeriodStats |
Protected Member Functions | |
bool | Write (mtsStateDataId id, const mtsGenericObject &obj) |
Protected Attributes | |
size_t | HistoryLength |
size_t | IndexWriter |
size_t | IndexReader |
size_t | IndexDelayed |
size_t | Delay |
bool | AutomaticAdvanceFlag |
std::vector< mtsStateArrayBase * > | StateVector |
std::vector< mtsGenericObject * > | StateVectorElements |
std::vector< std::string > | StateVectorDataNames |
std::vector< AccessorBase * > | StateVectorAccessors |
std::vector < mtsStateIndex::TimeTicksType > | Ticks |
mtsStateDataId | TicId |
mtsStateDataId | TocId |
mtsStateDataId | PeriodId |
const osaTimeServer * | TimeServer |
double | SumOfPeriods |
double | AveragePeriod |
std::string | Name |
DataCollectionInfo | DataCollection |
Friends | |
class | mtsCollectorState |
class | mtsComponent |
class | mtsTaskTest |
class | mtsStateTableTest |
class | mtsCollectorBaseTest |
The state data table is the storage for the state of the task that the table is associated with. It is a heterogenous circular buffer and can contain data of any type so long as it is derived from mtsGenericObject. The state data table also resolves conflicts between reads and writes to the state, by ensuring that the reader head is always one behind the write head. To ensure this we have an assumption here that there is only one writer, though there can be multiple readers. State Data Table is also refered as Data Table or State Table elsewhere in the documentation.
mtsStateTable::mtsStateTable | ( | size_t | size, |
const std::string & | name | ||
) |
Constructor. Constructs a state table with a default size of 256 rows.
mtsStateTable::~mtsStateTable | ( | ) |
Default destructor.
|
inline |
Add an element to the table (alternative to NewElement).
void mtsStateTable::Advance | ( | void | ) |
Advance the pointers of the circular buffer. Note that since there is only a single writer, it is not necessary to use mutual exclusion primitives; the critical section can be handled by updating (incrementing) the write index before the read index.
void mtsStateTable::AdvanceIfAutomatic | ( | void | ) |
Advance if automatic advance is set and does nothing otherwise.
|
inline |
Get method for auto advance flag. See AutomaticAdvanceFlag
void mtsStateTable::Cleanup | ( | void | ) |
Cleanup called when the task is being stopped.
void mtsStateTable::CSVWrite | ( | std::ostream & | out, |
bool | nonZeroOnly = false |
||
) |
This method is to dump the state data table in the csv format, allowing easy import into matlab. Assumes that individual columns are also printed in csv format. By default print all rows, if nonZeroOnly == true then print only those rows which have a nonzero Ticks value i.e, those rows that have been written to at least once.
void mtsStateTable::CSVWrite | ( | std::ostream & | out, |
unsigned int * | listColumn, | ||
unsigned int | number, | ||
bool | nonZeroOnly = false |
||
) |
void mtsStateTable::CSVWrite | ( | std::ostream & | out, |
mtsGenericObject ** | listColumn, | ||
unsigned int | number, | ||
bool | nonZeroOnly = false |
||
) |
void mtsStateTable::DataCollectionEventTriggeringRatio | ( | const mtsDouble & | eventTriggeringRatio | ) |
Determine a ratio to generate a data collection event.
void mtsStateTable::DataCollectionStart | ( | const mtsDouble & | delay | ) |
Methods used to control the data collection start/stop
void mtsStateTable::DataCollectionStop | ( | const mtsDouble & | delay | ) |
void mtsStateTable::Debug | ( | std::ostream & | out, |
unsigned int * | listColumn, | ||
unsigned int | number | ||
) | const |
For debugging, dumps some values of the current data table to output stream.
mtsStateTable::AccessorBase* mtsStateTable::GetAccessor | ( | const _elementType & | element | ) | const |
Return pointer to accessor functions for the state data element.
element | Pointer to state data element (i.e., working copy) |
mtsStateTable::AccessorBase* mtsStateTable::GetAccessor | ( | const std::string & | name | ) | const |
Return pointer to accessor functions for the state data element.
name | Name of state data element |
mtsStateTable::AccessorBase* mtsStateTable::GetAccessor | ( | const char * | name | ) | const |
mtsStateTable::AccessorBase* mtsStateTable::GetAccessor | ( | const size_t | id | ) | const |
mtsStateTable::AccessorBase* mtsStateTable::GetAccessor | ( | const _elementType & | element | ) | const |
|
inline |
Return the moving average of the measured period (i.e., average of last HistoryLength values).
|
inline |
mtsStateIndex mtsStateTable::GetIndexDelayed | ( | void | ) | const |
Get a handle for data to be used by a reader with a given delay. All the const methods, that can be called from a reader and writer.
mtsStateIndex mtsStateTable::GetIndexReader | ( | void | ) | const |
Get a handle for data to be used by a reader. All the const methods, that can be called from a reader and writer.
|
inline |
mtsStateIndex mtsStateTable::GetIndexWriter | ( | void | ) | const |
Get a handle for data to be used by a writer
|
inline |
Return the name of this state table.
|
inline |
|
inline |
Return pointer to the state data element specified by the id. This element is the same type as the state data table entry.
|
inline |
int mtsStateTable::GetStateVectorID | ( | const std::string & | dataName | ) | const |
Check if the signal has been registered.
|
inline |
|
inline |
mtsStateDataId mtsStateTable::NewElement | ( | const std::string & | name = "" , |
_elementType * | element = 0 |
||
) |
Add an element to the table. Should be called during startup of a real time loop. All the non-const methods, that can be called from a writer only. Returns index of data within state data table.
bool mtsStateTable::ReplayAdvance | ( | void | ) |
Advance for replay mode, be very careful this should only be used in replay mode as this method only increments the reader index.
|
inline |
Set method for auto advance flag. See AutoAdvanceFlag.
size_t mtsStateTable::SetDelay | ( | size_t | newDelay | ) |
Set delay in number of rows.
bool mtsStateTable::SetSize | ( | const size_t | size | ) |
Method to change the size of the table
void mtsStateTable::Start | ( | void | ) |
Start the current cycle. This just records the starting timestamp (Tic).
void mtsStateTable::StartIfAutomatic | ( | void | ) |
Start if automatic advance is set and does nothing otherwise.
|
virtual |
For debugging, dumps the current data table to output stream.
Reimplemented from cmnGenericObject.
|
inline |
Verifies if the data is valid.
|
protected |
Write specified data.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Automatic advance flag. This flag is used by the method AdvanceIfAutomatic to decide if this state table should advance or not. The method AdvanceIsAutomatic is used by mtsTask on all the registered state tables. If a user wishes to Advance the state table manually, he or she will have to set this flag to false (see SetAutomaticAdvance). This flag is set to true by default.
|
protected |
The average period over the last HistoryLength samples.
|
protected |
Information used for the state table data collection, see also mtsCollectorState.
|
protected |
Delay used for GetIndexDelayed and GetDelayed. In number of rows in state tables.
|
protected |
The number of rows of the state data table.
|
protected |
The index of the delayed reader in the table.
|
protected |
The index of the reader in the table.
|
protected |
The index of the writer in the data table.
|
protected |
The name of this state table.
mtsDouble mtsStateTable::Period |
The measured task period (difference between current Tic and previous Tic).
|
protected |
mtsIntervalStatistics mtsStateTable::PeriodStats |
Periodicist Statistics
|
protected |
The vector contains pointers to individual columns.
|
protected |
The vector contains pointers to the accessor methods (e.g., Get, GetLatest) from which command objects are created.
|
protected |
The columns entries can be accessed by name. This vector stores the names corresponding to the columns.
|
protected |
The vector contains pointers to the current values of elements that are to be added to the state when we advance.
|
protected |
The sum of all the periods (time differences between consecutive Tic values); used to compute average period.
mtsDouble mtsStateTable::Tic |
|
protected |
The state table indices for Tic, Toc, and Period.
|
protected |
The vector contains the time stamp in counts or ticks per period of the task that the state table is associated with.
|
protected |
The time server used to provide absolute and relative times.
mtsDouble mtsStateTable::Toc |
|
protected |