1 #ifndef CARMA_MONITOR_SUBSYSTEMFRAME_H
2 #define CARMA_MONITOR_SUBSYSTEMFRAME_H
20 #include "carma/monitor/SubsystemFrameHeader.h"
28 void SetFlag(
unsigned short & flags,
29 const unsigned short & mask );
31 void UnsetFlag(
unsigned short & flags,
32 const unsigned short & mask );
34 unsigned short GetFlag(
const unsigned short & flags,
35 const unsigned short & mask );
42 struct SubsystemDataPointers;
44 class MonitorPointSet;
45 struct TransportSubsystemFrame;
83 static const int MONITOR_POINT_ABSENT = -1;
95 const SubsystemDataPointers & getSubsystemDataPointers()
const;
122 static bool mjdIsCurrentFrame(
double mjd,
double * mjdDelta );
188 int getIndex (
const tagIDType tagID)
const;
196 tagIDType
getTagID (
const int index)
const ;
205 bool isValid (
const tagIDType tagID)
const ;
246 const long maxSamples) ;
260 static size_t sizeFrame (
long maxMonitorPoints,
long maxSamples);
276 SubsystemDataPointers & dataPointers,
277 long maxMonitorPoints,
292 SubsystemDataPointers & dataPointers );
420 ushort iSample)
const ;
519 void setLastWriteTime( );
558 void setScriberWriteTime( );
575 void setPublishTime( );
592 void setReceiveTime( );
659 ushort nSamplesPerCycle;
675 bool markMpsAsModified =
true );
685 SubsystemDataPointers & dataPointers,
686 bool embeddedInAFullSystem );
799 unsigned short numMonitorPoints,
800 unsigned short numSamples,
836 ushort nSamplesPerCycle = 1);
883 const MonitorHeader & getMonitorHeaderRefByIndex(
int index )
const;
884 MonitorHeader & getWritableMonitorHeaderRefByIndex(
int index )
const;
895 SubsystemDataPointers & dataPointers_;
898 const bool shouldDeallocateStorage_;
899 const bool embeddedInAFullSystem_;
901 ::std::map< MonitorValueType, unsigned int > highwaterMonitorSamples_;
918 const char* fileName = __FILE__,
919 const int lineNum = __LINE__) ;
921 const char* fileName = __FILE__,
922 const int lineNum = __LINE__) ;
924 const ushort subsystemID,
925 const char* fileName = __FILE__,
926 const int lineNum = __LINE__) ;
931 SetFlag(
unsigned short & flags,
932 const unsigned short & mask ) {
938 UnsetFlag(
unsigned short & flags,
939 const unsigned short & mask ) {
944 inline unsigned short
945 GetFlag(
const unsigned short & flags,
946 const unsigned short & mask ) {
947 return (flags & mask);
958 return frame_.numMonitorPoints;
962 inline unsigned short
965 return frame_.subsystemID;
983 inline const carma::monitor::SubsystemDataPointers &
984 carma::monitor::SubsystemFrame::getSubsystemDataPointers( )
const
986 return dataPointers_;
993 return frame_.numSamples;
997 inline const carma::monitor::MonitorHeader &
998 carma::monitor::SubsystemFrame::getMonitorHeaderRefByIndex(
999 const int index )
const
1001 return dataPointers_.monitorHeaders[ index ];
1005 inline unsigned short
1008 return getMonitorHeaderRefByIndex( index ).getNumSamplesPerCycle();
long getMaxNumMonitorPoints() const
Returns maximum number of monitor points this subsystem frame can accommodate.
MonitorValueType getValueType(const tagIDType tagID) const
Returns type of sample value associated with the monitor point specified by tagID.
const MonitorPointSample getSampleAverage(const tagIDType tagID) const
Returns average of all samples in current cycle as a MonitorPointSample object.
bool isPublished() const
True if this subsystem frame has been published.
short MonitorValueType
Enumeration of possible types for monitor point values.
void setStatusFlags(uchar status)
Sets status flags for subsystem frame.
const SubsystemHeader & getSubsystemHeader() const
Returns reference to internal structure.
void setScriberWriteTime(double mjdTimestamp)
Sets the time of the last scriber write to the associated subsystem IPQ.
void setNumActualSamples(ushort numSamples)
Sets number of actual monitor samples for this subsystem frame.
bool received() const
True if this subsystem frame has been received by the frame collator (in the ACC).
void clearAllTimes()
Resets lastWriteTime, scriberWriteTime, publishTime and receiveTime to 0.
void clearReceived()
Clears status flag to indicate that this frame has not been received.
void setReceiveTime(double mjdTimestamp)
Sets the time when this subsystem frame was received at the ACC.
This is the include file for Carma exception handling utilities.
Class representing a data sample for a MonitorPoint.
void setScriberWriteDelay(double writeDelay)
Sets the delay used by the scriber part of the frameScriberPublisher to write to the associated IPQ i...
static long maxNumSamplesIncludingAverages(const long maxMonitorPoints, const long maxSamples)
Returns number of samples to allocate for the entire subsystem given the maximum number of monitor po...
void setMonitorPointSet(MonitorPointSet *set)
Used when subsystem frame is generated from a MonitorPointSet object using the MonitorPointSet::getSu...
A class that manages the sets of monitor points for a monitor subsystem.
long getNumSingleSamplePoints() const
Returns total allocated number of monitor points with one sample per cycle, a sampling rate of 2 Hz...
double getReceiveTime() const
Returns the time when this subsystem frame was received at the ACC.
void allocateMonitorPoints(const AllocMpInfo *infos, size_t infosCount, bool markMpsAsModified=true)
method to allocate space within the subsystem frame for a monitor point and its samples.
double getPublishTime() const
Returns the time when this subsystem frame was published to the ACC.
MonitorPointSample getSampleValue(const tagIDType tagID, ushort iSample) const
Returns requested monitor sample as a MonitorPointSample object.
void setPublished()
Sets status flag to indicate that this frame is published.
ushort getNumSamplesPerCycle(const tagIDType tagID) const
Returns number of samples per cycle (0.5*sampling rate) associated with the monitor point with tagID ...
static size_t sizeFrame(long maxMonitorPoints, long maxSamples)
This method is used to compute the size of a subsystem frame when the the maximum number of monitor p...
tagIDType getTagID(const int index) const
Returns tagID of the monitor point with header at index "index" in the monitorHeaders array in this s...
void writeToTransport(TransportSubsystemFrame &transFrame)
Returns a TransportSubsystemFrame filled with monitor sample values from this subsystem frame...
unsigned int getHighwaterNumMonitorSamples(MonitorValueType type)
Get highwater number of monitor samples.
Contains sample values from all monitor points in a monitor subsystem.
static long computeCurrentFrameTime()
Static method used to calculate frame count as number of half-seconds since Januray 1...
Structure for storing monitor point sample, including value.
MonitorPointHeader getHeaderByIndex(int index) const
Returns maximum number of monitor samples this subsystem frame can accommodate.
SubsystemFrame(SubsystemHeader &frame, SubsystemDataPointers &dataPointers, bool embeddedInAFullSystem)
Constructor that constructs around a SubsystemHeader structure.
virtual ~SubsystemFrame()
Destructor.
long getMaxNumSamples() const
Returns maximum number of monitor samples this subsystem frame can accommodate.
void setReceived()
Sets status flag to indicate that this frame was received.
void markFramePublished()
Convenience method that sets the publish time and sets the status flag to indicate that the frame was...
MonitorPointHeader getHeaderByTagID(const tagIDType tagID) const
Returns MonitorPointHeader object corresponding to the monitor point with the specified tagID...
double getScriberWriteDelay() const
Returns the delay used by the scriber part of the frameScriberPublisher to write to the associated IP...
void writeFromTransportFrame(const TransportSubsystemFrame &transFrame)
Takes the sample values from a transported subsystem frame and fills them into this subsystem frame...
void setLastWriteTime(double mjdTimestamp)
Sets the time of the last client write to the associated frame scriber publisher process.
void setLastWriterDelay(double time)
Sets the delay used by the last client to write to the associated frame scriber publisher process...
void writeSampleValue(const int index, const MonitorSampleValue &value, ushort iSample)
Writes specified sample value 'value' into this subsystem frame as sample with sample number 'iSample...
uchar getStatusFlags() const
Returns status flags for subsystem frame.
void writeFromPointSet(const MonitorSampleValues &samples)
Takes the sample values from a transported sequence of sample values and fills them into this subsyst...
Base exception class for managing carma errors.
void setPublishTime(double mjdTimestamp)
Sets the time when this subsystem frame was published to the ACC.
int findMonitorPoint(const tagIDType tagID) const
Returns the index to the monitor point header corresponding to specified 'tagID'. ...
void setNumMonitorSamples(ushort numSamples)
Sets number of monitor samples for this subsystem frame.
bool isCurrentFrame() const
Method returns true if frame's timestamp is current; false otherwise.
void clearSamples()
Clears all samples in this subsystem frame.
void markFrameReceived()
Convenience method that sets the recive time and sets the status flag to indicate that the frame was ...
static ushort numSamplesToAllocate(const ushort nSamplesPerCycle)
Returns the number of samples to allocate for a sampling rate specified as number of samples per cycl...
long getNumMonitorPoints() const
Returns allocated number of monitor points - in other words, the actual number of monitor points pres...
ushort allocateSamples(int headerOffset, ushort sampleOffset, ushort nSamplesPerCycle=1)
Allocates monitor samples in this subsystem frame for a monitor point with header at 'headerOffset'...
ushort getSubsystemID() const
Returns subsystemID of this subsystem frame.
void setNumSingleSamplePoints(const long numSingleSamples)
Sets total allocated number of monitor points with one sample per cycle, a sampling rate of 2 Hz...
int getNumAllocatedSamples() const
Returns the number of allocated samples.
Class wrapper for monitor point samples stored in a subsystem frame.
double getLastWriterDelay() const
Returns the delay used by the last client to write to the associated frame scriber publisher process...
long getNumMonitorSamples() const
Returns total allocated number of monitor samples in this subsystem frame.
void setNumSamplesPerCycle(int index, const ushort samples)
Sets number of samples per cycle (0.5*sampling rate) associated with the monitor point at index == 'i...
double getLastWriteTime() const
Gets the time of the last client write to the associated frame scriber publisher process.
MonitorSampleValue * getSamples() const
Returns pointer to beginning of monitor sample array in this subsystem frame.
void setSubsystemID(ushort subsystemID)
Sets subsystemID of this subsystem frame.
type definitions for monitor system
int getIndex(const tagIDType tagID) const
Returns index of monitor point header corresponding to the specified tagID, in monitor header array i...
Frame containing monitor points for a monitor subsystem frame.
void setNumMonitorPoints(ushort numMonitorPoints)
Sets number of monitor points for this subsystem frame.
long countNumSingleSamplePoints() const
Counts number of single sample monitor points in this subsystem frame.
long setFrameCount(const long frameCount)
Sets the frame's timestamp.
Exception class thrown when an invalid monitor point is detected.
static void setFrameSize(SubsystemHeader &frame, SubsystemDataPointers &dataPointers, long maxMonitorPoints, long maxSamples)
Sets size parameters in the subsystem frame.
int getNumActualSamples() const
Returns number of monitor samples for this subsystem frame.
void consolidateSamples()
Consolidates storage in the array of monitor samples.
long getFrameCount() const
Gets the frame's timestamp.
double getScriberWriteTime() const
Gets the time of the last scriber write to the associated subsystem IPQ.
void clearPublished()
Clears status flag to indicate that this frame is not published.
bool isValid(const tagIDType tagID) const
True if tagID is that of a valid monitor point within this subsystem frame.
void syncSubsystemToNewFrameData()
Sets the pointers to the monitor point index array (monitorPointIndex), monitor point header array (m...
bool validSampleValue(const tagIDType tagID, const MonitorPointSample &value) const
True if sample is valid - this means that the tagID of the monitor point is valid in this subsystem f...