CARMA C++
carma::monitor::MonitorSubsystem Class Referenceabstract

Abstract MonitorSubsystem base class. More...

#include <carma/monitor/MonitorSubsystem.h>

Inheritance diagram for carma::monitor::MonitorSubsystem:
carma::monitor::MonitorSystemContainer carma::monitor::MonitorContainer carma::monitor::MonitorComponent

Public Member Functions

bool autoWriterIsAlive () const
 Test whether the auto-writer thread is alive (running). More...
 
bool configure ()
 Configure does the complete setup of a monitor subsystem The steps are: More...
 
virtual void createHierarchy ()=0
 Create all typed monitor points and hierarchy Every subsystem must define this. More...
 
double getEndWriteTime () const
 Time the last monitor point set write was finished. More...
 
int getFrameCount () const
 Get the frame count for the last read frame. More...
 
double getFrameTime () const
 Get the mjd associated with the frame. More...
 
double getLastWriterDelay () const
 The next few methods measure performance of monitor data transport. More...
 
double getLastWriteTime () const
 Time (MJD) of the last write to the ScriberPublisher. More...
 
MonitorPointSetgetMonitorPointSet ()
 Get the monitor point set. More...
 
double getPublishTime () const
 Get the mjd when the frame was published by the subsystem. More...
 
double getReceiveTime () const
 Get the mjd when the frame was received by the ACC. More...
 
double getScriberWriteDelay () const
 Offset from the half-second for writing this subsystem frame to the (local) subsystem IPQ. More...
 
double getScriberWriteTime () const
 Time this frame of data was written to the subsystem IPQ. More...
 
double getStartScriberWriteTime () const
 Time the last write was received on the ScriberPublisher. More...
 
double getStartWriteTime () const
 Time the last monitor point set write was started. More...
 
bool isCurrent () const
 Returns true if the monitor subsystem contains data that is current. More...
 
bool isCurrent (long frameCount) const
 Returns true if the monitor subsystem contains data that belongs to the timestamp. More...
 
bool isSubsystem () const
 Check if the component is a MonitorSubsystem. More...
 
int maxMonitorPoints () const
 Return the size of the storage allocated for monitor points. More...
 
int maxSamples () const
 Return the size of the storage allocated for monitor samples. More...
 
MonitorPointSetmonitorPointSet ()
 Get reference to the underlying storage. More...
 
 MonitorSubsystem (const std::string &subsystemName, SystemFrameBuffer *buffer=0, int maxMonitorPoints=600, int maxSamples=1800, ARCHIVE_PRIORITY archivePriority=NORMAL, bool onlyDEFAULT=true)
 Constructor base subsystem configuration The derived class object must be configure() after construction The name is used to lookup the subsystem ID, so only specific subsystem names are allowed. More...
 
unsigned int read ()
 Reads oldest unread data from the IPQ into the local set of monitor points. More...
 
bool readNewest ()
 Reads in the newest data from the IPQ into the local set of monitor points. More...
 
bool readNewestConditionalCopy ()
 If new data is available it is copied from the queue into the monitor system. More...
 
void resetTimes ()
 
void resetValidity ()
 Reset validity flags of all data. More...
 
void startAutoWriter (double delay) const
 method to configure and start the auto-write thread. More...
 
void stopAutoWriter () const
 Stop the auto-write thread. More...
 
virtual std::string transportStatisticsToString (bool canonical=false) const
 Dumps transport statistics as a table, with write delays, and transport/write times printed out as doubles, with fixed precision. More...
 
void updateFrameAverage ()
 Average and ave validity is computed and set for each monitor point over all samples in the frame. More...
 
void write ()
 Write out the monitor point data values. More...
 
void writeWithoutResettingValidities ()
 
virtual ~MonitorSubsystem ()
 Destructor. More...
 
- Public Member Functions inherited from carma::monitor::MonitorSystemContainer
bool isActive ()
 Checks to see if this system is actively receiving data. More...
 
 MonitorSystemContainer (const std::string &systemName)
 Constructor base subsystem configuration. More...
 
virtual bool readNewestIfStale ()
 Reads in data from the IPQ into the local set of monitor points if data is stale, that is, !isCurrent(). More...
 
virtual ~MonitorSystemContainer ()
 Destructor. More...
 
- Public Member Functions inherited from carma::monitor::MonitorContainer
void add (MonitorComponent &component)
 Add a subcomponent to this container A reference is kept to this subcomponent, so the caller is responsible for managing the lifecycle of the subcomponent; this container simply expects that it be available for access. More...
 
const Child & getChild (int index) const
 Get reference to child monitor component by index. More...
 
::std::vector< Child > getChildVec () const
 Get a vector of monitor components contained by this component. More...
 
MonitorComponentgetComponentPtr (const ::std::string &name, bool caseSensitive) const
 Get a contained monitor component by hierarchical name The hierarchical name starts below this container and consist of dot (".") separated components. More...
 
MonitorPointgetFirstMonitorPoint ()
 Recursively find the first monitor point in this container. More...
 
MonitorPointgetMonitorPoint (const std::string &name, bool caseSensitive) const
 Get a monitor point by name (hierarchical name OK). More...
 
MonitorPointgetMonitorPoint (tagIDType tagID) const
 Get a monitor point by tagID. More...
 
MonitorPointgetMonitorPointPtr (const std::string &name, bool caseSensitive) const
 
MonitorPointgetMonitorPointPtr (tagIDType tagID) const
 
int getNumChildren () const
 Get the number of monitor components contained by this component. More...
 
virtual int getNumContainerChildren () const
 Get the number of child monitor containers contained by this component. More...
 
virtual int getNumContainerDescendants () const
 Get the number of child monitor containers contained by this component and it's children. More...
 
virtual int getNumDescendants () const
 Get the total number of monitor components contained by this component and it's children. More...
 
int getNumMonitorPoints (bool recurse=false) const
 Get the number of monitor points. More...
 
int getNumMonitorPoints ()
 Get the total number of monitor points in this container. More...
 
int getNumSamples ()
 Get the total number of samples in this container. More...
 
bool hasAllData () const
 See if all MPs in this component and below have data samples. More...
 
virtual ::std::string hierarchyToString (bool canonical=false, bool verbose=false, bool value=true, int sampleIndex=0, int indent=0, int levels=-1) const
 Dump this and all contained monitor components to a string. More...
 
virtual ::std::string hierarchyToStringAverage (bool canonical=false, bool verbose=false, bool value=true, int indent=0, int levels=-1) const
 Dump this and all contained monitor components to a string. More...
 
virtual void hierarchyToVector (::std::vector< ::std::string > &hierarchyList, bool canonical=false, bool verbose=false, int sampleIndex=0) const
 Dump this and all contained monitor component strings into a map hierarchy. More...
 
virtual std::string leafToString (bool verbose=false, bool value=true, int sampleIndex=0) const
 Dump all leaf nodes below this component to a string. More...
 
 MonitorContainer (const ::std::string &name)
 Constructor. More...
 
virtual ::std::string monitorPointTags (bool untagged=false) const
 Write list of monitor points and their tagIDs to a string, one monitor point per line. More...
 
virtual bool operator== (const MonitorComponent &component) const
 Compares this monitor container for equality to the one passed. More...
 
void setArchivePriority (const MonitorComponent::ARCHIVE_PRIORITY priority, bool onlyDEFAULT=true)
 Recursively set the archive priority of all monitor points below. More...
 
virtual void setCanonicalName (const std::string &parents)
 Recursively set the canonical component name for this and all below. More...
 
virtual void setMonitorPointAttributes ()
 Set attributes of all monitor points held anywhere in the hierarchy within (and below) this container. More...
 
void setNoData () const
 Recursively mark all data samples as INVALID_NO_DATA. More...
 
void setPersistent (bool persistent)
 Set the persistent attribute for the value of a MonitorPoint, or in the case of a container for its descendants (recursively). More...
 
void setValidity (MonitorPoint::VALIDITY validity)
 Recursively set validity for all samples of all monitor points below this container. More...
 
std::string toString (bool canonicalName=false, bool verbose=false, bool value=true, int sampleIndex=0, int indent=0) const
 Write this monitor component to a string. More...
 
std::string toStringAverage (bool canonicalName=false, bool verbose=false, bool value=true, int indent=0) const
 Write this monitor component to a string, using frame average values. More...
 
 ~MonitorContainer ()
 Destructor. More...
 
- Public Member Functions inherited from carma::monitor::MonitorComponent
const std::string & getCanonicalName () const
 Get the canonical component name. More...
 
virtual const std::string & getDescription () const
 Get the verbose description of the monitor component. More...
 
virtual const std::string & getLongName () const
 Get the long name of the monitor component. More...
 
virtual const std::string & getName () const
 Get the component name (leaf part of canonical name). More...
 
virtual std::string getPhysicalDeviceName () const
 Get the physical device name, if one exists. More...
 
std::string getPhysicalDeviceString () const
 Get the physical device name, if one exists, enclosed in parentheses. More...
 
std::string getPhysicalName () const
 Get the physical name, which is location.device.component or if there is no associated physical device it is just component name. More...
 
virtual const std::string & getShortName () const
 Get the short name of the monitor component. More...
 
virtual bool isMonitorPoint () const
 Identifies this component as a MonitorPoint or any derivative Should be over-ridden by the MonitorPoint class; others that don't derive from MP can use this default implementation. More...
 
 MonitorComponent (const std::string &name)
 Constructor. More...
 
bool operator!= (const MonitorComponent &component) const
 Checks if components are not equal. More...
 
void setDescription (const std::string &text)
 Set the verbose description of the monitor component. More...
 
void setLongName (const std::string &name)
 Set the long name of the monitor component. More...
 
void setName (const std::string &name)
 Set the leaf part of the canonical name of the monitor component. More...
 
void setShortName (const std::string &name)
 Set the short name of the monitor component. More...
 
void setShortName (const std::string &name, int index)
 Set the short name of the monitor component, with an index appended. More...
 
virtual ~MonitorComponent ()
 Destructor. More...
 

Static Public Member Functions

static std::string makeName (const std::string &name, int number)
 Form a name string that is a root followed by an integer, e.g. More...
 
static std::string transportHeaderToString ()
 Dumps transport statistics table header, with legends for columns. More...
 
- Static Public Member Functions inherited from carma::monitor::MonitorComponent
static std::string archivePriorityToString (MonitorComponent::ARCHIVE_PRIORITY priority)
 Get a string representation for an archive priority. More...
 
static std::string convertAllLower (std::string name)
 Convert a name to all lower case. More...
 

Additional Inherited Members

- Public Types inherited from carma::monitor::MonitorComponent
enum  ARCHIVE_PRIORITY {
  VITAL, USEFUL, NORMAL, DEBUG,
  VERBOSE, DEFAULT, DONTARCHIVE
}
 Archiving priority. More...
 
- Protected Member Functions inherited from carma::monitor::MonitorContainer
virtual void setLocalMonitorPointAttributes ()
 Set attributes of all monitor points held directly by this container. More...
 
- Static Protected Member Functions inherited from carma::monitor::MonitorContainer
static Child findDescendant (const MonitorContainer &rootContainer, const ::std::string &name, bool caseSensitive)
 
- Protected Attributes inherited from carma::monitor::MonitorComponent
bool debug_
 

Detailed Description

Abstract MonitorSubsystem base class.

The distinguishing feature of this monitor container is the associated Frame and the virtual configuration methods that must be supplied by the derived class. The configuration steps used internally are:
create hierarchy of typed monitor points - specific subsystem
set tagIDs and canonical names for all MPs - this class
(but it must lookup tagIDs using specific subsystem lookup) set other params for all MPs - specific subsystem
The other params for the MPs may be set when the hierarchy is built or driven from a table/file/database.

Subsystem names are forced to have the first character UC, and all others LC.

After the derived MonitorSubsystem is instantiated it must be configured with the configure() method.

Definition at line 53 of file MonitorSubsystem.h.

Constructor & Destructor Documentation

carma::monitor::MonitorSubsystem::MonitorSubsystem ( const std::string &  subsystemName,
SystemFrameBuffer *  buffer = 0,
int  maxMonitorPoints = 600,
int  maxSamples = 1800,
ARCHIVE_PRIORITY  archivePriority = NORMAL,
bool  onlyDEFAULT = true 
)

Constructor base subsystem configuration The derived class object must be configure() after construction The name is used to lookup the subsystem ID, so only specific subsystem names are allowed.

See Also
SubsystemTagIDmap
Parameters
subsystemNamemonitor subsystem name
bufferpointer to storage on ACC; NULL if within subsystem
maxMonitorPointsstorage to be allocated for monitor points
maxSamplesstorage to be allocated for monitor sample values
archivePriorityarchive priority to set for all points
onlyDEFAULTif true, only set arcPriority for points that have DEFAULT priority, otherwise set all of them
virtual carma::monitor::MonitorSubsystem::~MonitorSubsystem ( )
virtual

Destructor.

Member Function Documentation

bool carma::monitor::MonitorSubsystem::autoWriterIsAlive ( ) const

Test whether the auto-writer thread is alive (running).

Returns
true if auto-writer thread is alive, false otherwise.
bool carma::monitor::MonitorSubsystem::configure ( )

Configure does the complete setup of a monitor subsystem The steps are:

  • create typed monitor points and hierarchy (
    See Also
    createHierarchy)
  • set identity for all monitor points (canonical name and tagID) (
    See Also
    setIdentity)
  • allocates space in Frame (
    See Also
    allocateAllMonitorPoints)
  • sets any other monitor point attributes (
    See Also
    setMonitorPointAttributes)
    This can't be run in the constructor because calls pure virtual methods
Returns
true if successful configuration
virtual void carma::monitor::MonitorSubsystem::createHierarchy ( )
pure virtual

Create all typed monitor points and hierarchy Every subsystem must define this.

See Also
configure
double carma::monitor::MonitorSubsystem::getEndWriteTime ( ) const

Time the last monitor point set write was finished.

Returns
double - MJD when the monitor point set write was finished
int carma::monitor::MonitorSubsystem::getFrameCount ( ) const
virtual

Get the frame count for the last read frame.

Implements carma::monitor::MonitorSystemContainer.

double carma::monitor::MonitorSubsystem::getFrameTime ( ) const

Get the mjd associated with the frame.

double carma::monitor::MonitorSubsystem::getLastWriterDelay ( ) const

The next few methods measure performance of monitor data transport.

They provide the following data:

a) delay associated with the last autowriter thread to write to the ScriberPublisher b) time of the last write to the ScriberPublisher (manual or auto) c) write delay associated with ScriberPublisher writing to the IPQ d) actual time of writing to the IPQ

All times and delays are doubles, measured in seconds. All delays are measured from the corrected UTC half-second time tick. Offset from the half-second for the last auto writer thread.

Returns
double - offset from the half-second, in seconds.
double carma::monitor::MonitorSubsystem::getLastWriteTime ( ) const

Time (MJD) of the last write to the ScriberPublisher.

Returns
double - MJD, as a double.
MonitorPointSet& carma::monitor::MonitorSubsystem::getMonitorPointSet ( )

Get the monitor point set.

Returns
reference to the monitor point set
double carma::monitor::MonitorSubsystem::getPublishTime ( ) const

Get the mjd when the frame was published by the subsystem.

Only valid in the ACC.

double carma::monitor::MonitorSubsystem::getReceiveTime ( ) const

Get the mjd when the frame was received by the ACC.

Only valid in the ACC.

double carma::monitor::MonitorSubsystem::getScriberWriteDelay ( ) const

Offset from the half-second for writing this subsystem frame to the (local) subsystem IPQ.

Returns
double - MJD when the monitor point set is to be written to the IPQ.
double carma::monitor::MonitorSubsystem::getScriberWriteTime ( ) const

Time this frame of data was written to the subsystem IPQ.

Returns
double - MJD when the monitor point set was written to the IPQ.
double carma::monitor::MonitorSubsystem::getStartScriberWriteTime ( ) const

Time the last write was received on the ScriberPublisher.

Returns
double - MJD when the monitor point set was rx'ed @ scriber
double carma::monitor::MonitorSubsystem::getStartWriteTime ( ) const

Time the last monitor point set write was started.

Returns
double - MJD when the monitor point set write was started
bool carma::monitor::MonitorSubsystem::isCurrent ( ) const
virtual

Returns true if the monitor subsystem contains data that is current.

A read could make the data current, and hence make isCurrent return true. If a read does not make isCurrent true, then the subsystem is probably broken.

Returns
bool true if data in subsystem is current.

Implements carma::monitor::MonitorSystemContainer.

bool carma::monitor::MonitorSubsystem::isCurrent ( long  frameCount) const

Returns true if the monitor subsystem contains data that belongs to the timestamp.

frameCount

.

Parameters
frameCountlong timestamp to match against timestamp for data in MonitorSubsystem
Returns
bool true if data in subsystem has timestamp == frameCount.
See Also
carma::monitor::MonitorSubsystem::getFrameCount()
bool carma::monitor::MonitorSubsystem::isSubsystem ( ) const
virtual

Check if the component is a MonitorSubsystem.

Returns
true if the component is a MonitorSubsystem

Reimplemented from carma::monitor::MonitorComponent.

static std::string carma::monitor::MonitorSubsystem::makeName ( const std::string &  name,
int  number 
)
static

Form a name string that is a root followed by an integer, e.g.

Bima9. This is a helper method used by subsystems to form their name.

Parameters
nameroot name
numberto append to the root
int carma::monitor::MonitorSubsystem::maxMonitorPoints ( ) const

Return the size of the storage allocated for monitor points.

int carma::monitor::MonitorSubsystem::maxSamples ( ) const

Return the size of the storage allocated for monitor samples.

MonitorPointSet& carma::monitor::MonitorSubsystem::monitorPointSet ( )

Get reference to the underlying storage.

unsigned int carma::monitor::MonitorSubsystem::read ( )
virtual

Reads oldest unread data from the IPQ into the local set of monitor points.

This is a blocking read.

Returns
number of elements lost in reading the queue (non-zero if the reads are so far apart in time that the queue has wrapped around.

Implements carma::monitor::MonitorSystemContainer.

bool carma::monitor::MonitorSubsystem::readNewest ( )
virtual

Reads in the newest data from the IPQ into the local set of monitor points.

There is no blocking!!

Returns
false if no data was available in the queue

Implements carma::monitor::MonitorSystemContainer.

bool carma::monitor::MonitorSubsystem::readNewestConditionalCopy ( )
virtual

If new data is available it is copied from the queue into the monitor system.

If no unread data is available then the method returns. In either case there is no blocking.

Returns
false if no data was copied

Implements carma::monitor::MonitorSystemContainer.

void carma::monitor::MonitorSubsystem::resetTimes ( )

Resets all times associated with transport performance. If these times are not reset, then the last set value remains even if no write/transport occurs.

void carma::monitor::MonitorSubsystem::resetValidity ( )

Reset validity flags of all data.

All monitor points that are not persistent have the validity set to INVALID_NO_DATA.

void carma::monitor::MonitorSubsystem::startAutoWriter ( double  delay) const

method to configure and start the auto-write thread.

This method configures and starts the thread for automatic writing. This method is a combination of configureAutoWriter and startAutoWriter. The parameter delay must be greater than zero.

double delay in seconds. delay must be less than or equal to MAX_AUTO_WRITE_DELAY and greater than zero as the auto-writer operates on a period of a half-second.

Returns
none
Exceptions
throwsan ErrorException if delay > MAX_AUTO_WRITE_DELAY
See Also
MAX_AUTO_WRITE_DELAY
AUTO_WRITE_DELAY
MonitorPointSet::configureAutoWriter
MonitorPointSet::startAutoWriter
void carma::monitor::MonitorSubsystem::stopAutoWriter ( ) const

Stop the auto-write thread.

This method stops the thread for automatic writing. The thread makes a clean exit, completing any pending write.

Returns
none
static std::string carma::monitor::MonitorSubsystem::transportHeaderToString ( )
static

Dumps transport statistics table header, with legends for columns.

virtual std::string carma::monitor::MonitorSubsystem::transportStatisticsToString ( bool  canonical = false) const
virtual

Dumps transport statistics as a table, with write delays, and transport/write times printed out as doubles, with fixed precision.

Parameters
canonicalbool if true, prints canonical name otherwise uses leaf name.
Returns
std::string returns transport statistics as a string

Reimplemented from carma::monitor::MonitorComponent.

void carma::monitor::MonitorSubsystem::updateFrameAverage ( )

Average and ave validity is computed and set for each monitor point over all samples in the frame.

void carma::monitor::MonitorSubsystem::write ( )
virtual

Write out the monitor point data values.

Implements carma::monitor::MonitorSystemContainer.


The documentation for this class was generated from the following file: