CARMA C++
SystemThresholdFrame.h
Go to the documentation of this file.
1 /*
2  * SystemThresholdFrame.h - Class holding thresholds for carma monitor system.
3  */
4 
5 #ifndef CARMA_SYSTEM_THRESHOLD_FRAME_H
6 #define CARMA_SYSTEM_THRESHOLD_FRAME_H
7 
20 #include "carma/monitor/types.h"
21 
22 namespace carma {
23 namespace monitor {
24 
25 
26 class MonitorSystem;
27 class MonitorPoint;
28 class MonitorPointThreshold;
29 struct ThresholdStruct;
30 
31 
39 {
40  public:
41 
42  ThresholdObjectNotFoundException ( tagIDType tagID,
43  const char * fileName,
44  int lineNo );
45 
46  ~ThresholdObjectNotFoundException () throw () { }
47 
48  private:
49 
60  static std::string makeMessage( tagIDType tagID );
61 };
62 
63 
71 {
72  public:
73 
74  ReachedNumThresholdLimitException( long maxThresholds,
75  tagIDType tagID,
76  const char * fileName,
77  int lineNo);
78 
79  ~ReachedNumThresholdLimitException () throw () { }
80 
81  private:
82 
95  static std::string makeMessage( long maxThresholds,
96  tagIDType tagID );
97 };
98 
99 
111  long maxNumThresholds; // # of thresholds that the frame can hold
112 
117  long numThresholds; // # of thresholds allocated within this frame
118 
124  int * thresholdIndex; // points to array of indices to thresholds
125 
131  ThresholdStruct * thresholds;
132 };
133 
134 
143 
144  public:
145 
151  explicit SystemThresholdFrame( MonitorSystem & monitorSystem );
152 
158  virtual ~SystemThresholdFrame() ;
159 
165  long getNumThresholds() const;
166 
172  long getMaxNumThresholds() const;
173 
179  virtual void calibrateMonitorSystem( );
180 
189  MonitorPointThreshold & getThreshold( tagIDType tagID ) const;
190 
191  protected:
192 
200 
212  ThresholdStruct & getThresholdStruct( int index ) const;
213 
221  int findThreshold( tagIDType tagID ) const;
222 
232  static size_t sizeThresholdFrame (long maxThresholds);
233 
244  static ThresholdFrameStruct &
246  long maxThresholds );
247 
257  static ThresholdFrameStruct &
259 
260  private:
261 
270  static ThresholdFrameStruct &
271  createThresholdFrameStruct( MonitorSystem & monitorSystem );
272 
273  static void
274  destroyThresholdFrameStruct( ThresholdFrameStruct & thresholdFrameStruct );
275 
283  void initializeThresholdValues( );
284 
285  struct MpThreshPair {
286  MonitorPoint * mp;
287  ThresholdStruct * thresholdStruct;
288  };
289 
295  ThresholdFrameStruct & thresholdFrame_;
296  MonitorSystem & monitorSystem_;
297  ::std::vector< MpThreshPair > mpThreshPairs_;
298 }; // class SystemThresholdFrame
299 
300 
301 } // namespace carma::monitor
302 } // namespace carma
303 
304 #endif
int findThreshold(tagIDType tagID) const
Searches for index to threshold with tagID.
long getMaxNumThresholds() const
Returns maximum number of allocatable thresholds.
static size_t sizeThresholdFrame(long maxThresholds)
Computes size of threshold frame required to hold.
Exception class for errors.
long getNumThresholds() const
Returns number of allocated thresholds.
int * thresholdIndex
Pointer to index of thresholds - index is arranged in ascending order of tagID&#39;s. ...
static ThresholdFrameStruct & setThresholdFrameSize(ThresholdFrameStruct &frame, long maxThresholds)
Initializes size related portions of ThresholdFrameStruct.
SystemThresholdFrame(MonitorSystem &monitorSystem)
Constructor - creates a struct using the MonitorSystem, initializes struct with the maxThresholds...
virtual ~SystemThresholdFrame()
Destructor - deletes frame structure.
Structure keeps track of sample properties of a monitor point for the purposes of calculating various...
Exception generated by SystemThreshdolFrame object when threshold object (specified by tagID) is not ...
long maxNumThresholds
Maximum number of thresholds that can be accomodated.
static ThresholdFrameStruct & fixupFramePointers(ThresholdFrameStruct &frame)
Initializes the pointers within the ThresholdFrameStruct to point to meaningful spaces based on the m...
ThresholdFrameStruct & getThresholdFrame() const
Returns reference to internal ThresholdFrameStruct.
Abstract base class for a monitor point.
Definition: MonitorPoint.h:68
Exception class for errors The exception comes with a text string that can be printed or logged...
Class that manages the thresholds for all the monitor points within a monitor system (represented by ...
ThresholdStruct & getThresholdStruct(int index) const
Returns reference to internal ThresholdStruct.
Monitor system base class.
Definition: MonitorSystem.h:81
MonitorPointThreshold & getThreshold(tagIDType tagID) const
Returns the MonitorPointThreshold object associated with the monitor point mp such that mp...
type definitions for monitor system
Exception generated by SystemThreshdolFrame object when threshold object (specified by tagID) cannot ...
ThresholdStruct * thresholds
Array of threshold objects - array size is equal to maxNumThresholds.
virtual void calibrateMonitorSystem()
Sets threshold related validity flags for all monitor points in the MonitorSystem.
long numThresholds
Actual number of thresholds that the frame is holding.