ERC CISST - cisst software

mtsStateTable Class Reference
[Multi Task Support]

#include <mtsStateTable.h>

Inheritance diagram for mtsStateTable:

Inheritance graph
[legend]
Collaboration diagram for mtsStateTable:

Collaboration graph
[legend]
List of all members.

Detailed Description

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.

Definition at line 70 of file mtsStateTable.h.

Public Member Functions

Public Attributes

Protected Member Functions

Protected Attributes

Friends

Classes


Constructor & Destructor 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.


Member Function Documentation

bool mtsStateTable::Write ( mtsStateDataId  id,
const mtsGenericObject obj 
) [protected]

Write specified data.

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.

bool mtsStateTable::ValidateReadIndex ( const mtsStateIndex timeIndex  )  const [inline]

Verifies if the data is valid.

Definition at line 334 of file mtsStateTable.h.

References mtsStateIndex::Index(), and mtsStateIndex::Ticks().

const bool& mtsStateTable::AutomaticAdvance ( void   )  const [inline]

Get method for auto advance flag. See AutomaticAdvanceFlag

Definition at line 339 of file mtsStateTable.h.

void mtsStateTable::SetAutomaticAdvance ( bool  automaticAdvance  )  [inline]

Set method for auto advance flag. See AutoAdvanceFlag.

Definition at line 344 of file mtsStateTable.h.

int mtsStateTable::GetStateVectorID ( const std::string &  dataName  )  const

Check if the signal has been registered.

template<class _elementType>
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.

Definition at line 480 of file mtsStateTable.h.

References mtsGenericTypes< T >::ConditionalWrap(), HistoryLength, StateVector, StateVectorAccessors, StateVectorDataNames, and StateVectorElements.

Referenced by mtsStateData< _elementType >::AddToStateTable().

template<class _elementType>
void mtsStateTable::AddData ( _elementType &  element,
const std::string &  name = "" 
) [inline]

Add an element to the table (alternative to NewElement).

Definition at line 360 of file mtsStateTable.h.

template<class _elementType>
_elementType* mtsStateTable::GetStateDataElement ( mtsStateDataId  id  )  const [inline]

Return pointer to the state data element specified by the id. This element is the same type as the state data table entry.

Definition at line 367 of file mtsStateTable.h.

template<class _elementType>
mtsStateTable::AccessorBase * mtsStateTable::GetAccessor ( const _elementType &  element  )  const

Return pointer to accessor functions for the state data element.

Parameters:
element Pointer to state data element (i.e., working copy)
Returns:
Pointer to accessor class (0 if not found)
Note:
This method is overloaded to accept the element pointer or string name.

Definition at line 496 of file mtsStateTable.h.

References StateVectorAccessors, and StateVectorElements.

Referenced by mtsInterfaceProvided::AddCommandReadHistory(), mtsInterfaceProvided::AddCommandReadState(), mtsInterfaceProvided::AddCommandWriteState(), and mtsStateData< _elementType >::AddToStateTable().

mtsStateTable::AccessorBase* mtsStateTable::GetAccessor ( const std::string &  name  )  const

Return pointer to accessor functions for the state data element.

Parameters:
name Name of state data element
Returns:
Pointer to accessor class (0 if not found)
Note:
This method is overloaded to accept the element pointer or string name.

mtsStateIndex mtsStateTable::GetIndexWriter ( void   )  const

Get a handle for data to be used by a writer

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.

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.

void mtsStateTable::Cleanup ( void   ) 

Cleanup called when the task is being stopped.

double mtsStateTable::GetAveragePeriod ( void   )  const [inline]

Return the moving average of the measured period (i.e., average of last HistoryLength values).

Definition at line 427 of file mtsStateTable.h.

void mtsStateTable::ToStream ( std::ostream &  out  )  const [virtual]

For debugging, dumps the current data table to output stream.

Reimplemented from cmnGenericObject.

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.

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.

const std::string& mtsStateTable::GetName ( void   )  const [inline]

Return the name of this state table.

Definition at line 450 of file mtsStateTable.h.

Referenced by mtsObjectName().

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  ) 

Methods used to control the data collection start/stop


Member Data Documentation

size_t mtsStateTable::HistoryLength [protected]

The number of rows of the state data table.

Definition at line 241 of file mtsStateTable.h.

Referenced by NewElement().

size_t mtsStateTable::IndexWriter [protected]

The index of the writer in the data table.

Definition at line 244 of file mtsStateTable.h.

size_t mtsStateTable::IndexReader [protected]

The index of the reader in the table.

Definition at line 247 of file mtsStateTable.h.

bool mtsStateTable::AutomaticAdvanceFlag [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.

Definition at line 256 of file mtsStateTable.h.

std::vector<mtsStateArrayBase *> mtsStateTable::StateVector [protected]

The vector contains pointers to individual columns.

Definition at line 259 of file mtsStateTable.h.

Referenced by NewElement().

std::vector<mtsGenericObject *> mtsStateTable::StateVectorElements [protected]

The vector contains pointers to the current values of elements that are to be added to the state when we advance.

Definition at line 265 of file mtsStateTable.h.

Referenced by GetAccessor(), and NewElement().

std::vector<std::string> mtsStateTable::StateVectorDataNames [protected]

The columns entries can be accessed by name. This vector stores the names corresponding to the columns.

Definition at line 269 of file mtsStateTable.h.

Referenced by NewElement().

std::vector<AccessorBase *> mtsStateTable::StateVectorAccessors [protected]

The vector contains pointers to the accessor methods (e.g., Get, GetLatest) from which command objects are created.

Definition at line 273 of file mtsStateTable.h.

Referenced by GetAccessor(), and NewElement().

std::vector<mtsStateIndex::TimeTicksType> mtsStateTable::Ticks [protected]

The vector contains the time stamp in counts or ticks per period of the task that the state table is associated with.

Definition at line 277 of file mtsStateTable.h.

mtsStateDataId mtsStateTable::TicId [protected]

The state table indices for Tic, Toc, and Period.

Definition at line 280 of file mtsStateTable.h.

const osaTimeServer* mtsStateTable::TimeServer [protected]

The time server used to provide absolute and relative times.

Definition at line 284 of file mtsStateTable.h.

mtsDouble mtsStateTable::Period

The measured task period (difference between current Tic and previous Tic).

Definition at line 293 of file mtsStateTable.h.

mtsIntervalStatistics mtsStateTable::PeriodStats

Periodicist Statistics

Definition at line 296 of file mtsStateTable.h.

double mtsStateTable::SumOfPeriods [protected]

The sum of all the periods (time differences between consecutive Tic values); used to compute average period.

Definition at line 301 of file mtsStateTable.h.

double mtsStateTable::AveragePeriod [protected]

The average period over the last HistoryLength samples.

Definition at line 304 of file mtsStateTable.h.

std::string mtsStateTable::Name [protected]

The name of this state table.

Definition at line 307 of file mtsStateTable.h.

DataCollectionInfo mtsStateTable::DataCollection [protected]

Information used for the state table data collection, see also mtsCollectorState.

Definition at line 311 of file mtsStateTable.h.


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu