CARMA C++
MonitorPointHeader.h
Go to the documentation of this file.
1 
12 #ifndef CARMA_MONITOR_MONITOR_POINT_HEADER_H
13 #define CARMA_MONITOR_MONITOR_POINT_HEADER_H
14 
15 #include "carma/monitor/types.h"
17 
18 
19 namespace carma {
20  namespace monitor {
21 
22 
23 class MonitorPointSet;
24 
25 
26 struct MonitorHeader {
27  tagIDType tagID;
28 
33  ushort sampleOffset;
34 
41  unsigned char nSamples;
42 
49  unsigned char type;
50 
51  static unsigned char valueType2Char( MonitorValueType mvt );
52 
53  static MonitorValueType char2ValueType( unsigned char uc );
54 
55  tagIDType getTagID( ) const;
56 
57  ushort getSampleOffset( ) const;
58 
59  ushort getNumSamplesPerCycle( ) const;
60 
61  MonitorValueType getValueType( ) const;
62  void setValueType( MonitorValueType mvt );
63 }; // 8 bytes
64 
65 
76  public:
106  MonitorPointHeader( MonitorHeader & header,
107  MonitorSampleValue * samples,
108  int index = -1,
109  MonitorPointSet * set = 0 );
110 
115 
125 
126 
137  tagIDType getTagID( ) const;
138 
152  ushort getNumSamplesPerCycle( ) const;
153 
166  void setNumSamplesPerCycle( const ushort nSamples );
167 
183  ushort getSampleOffset( ) const;
184 
199  void setSampleOffset (const ushort sampleOffset) { this->header_.sampleOffset = sampleOffset; }
200 
201  void setValueType( MonitorValueType mvt );
202 
203  MonitorValueType getValueType( ) const;
204 
205  const MonitorSampleValue & getMonitorSampleValueRef( int iSample ) const;
206  MonitorSampleValue & getMonitorSampleValueRef( int iSample );
207 
208  const MonitorSampleValue & getAverageMonitorSampleValueRef( ) const;
209  MonitorSampleValue & getAverageMonitorSampleValueRef( );
210 
225 
226 
240 
251  void clearSamples (bool deallocate = false);
252 
267  void setSamplesPerCycle (const ushort nSamples)
268  { this->header_.nSamples = nSamples; }
269 
270  private:
271 
281  MonitorHeader & header_;
282 
295  MonitorSampleValue* const samples_;
296 
303  const int index_;
304 
311  MonitorPointSet * const set_;
312 };
313 
314 
315 } } // namespace monitor, carma
316 
317 
318 inline unsigned char
319 carma::monitor::MonitorHeader::valueType2Char( const MonitorValueType mvt )
320 {
321  return static_cast< unsigned char >( mvt );
322 }
323 
324 
326 carma::monitor::MonitorHeader::char2ValueType( const unsigned char uc )
327 {
328  return static_cast< MonitorValueType >( uc );
329 }
330 
331 
332 inline carma::monitor::tagIDType
333 carma::monitor::MonitorHeader::getTagID( ) const
334 {
335  return tagID;
336 }
337 
338 
339 inline ushort
340 carma::monitor::MonitorHeader::getSampleOffset( ) const
341 {
342  return sampleOffset;
343 }
344 
345 
346 inline ushort
347 carma::monitor::MonitorHeader::getNumSamplesPerCycle( ) const
348 {
349  return nSamples;
350 }
351 
352 
354 carma::monitor::MonitorHeader::getValueType( ) const
355 {
356  return char2ValueType( type );
357 }
358 
359 
360 inline void
361 carma::monitor::MonitorHeader::setValueType( const MonitorValueType mvt )
362 {
363  type = valueType2Char( mvt );
364 }
365 
366 
367 inline
369  MonitorHeader & header,
370  MonitorSampleValue * const samples,
371  const int index,
372  MonitorPointSet * const set ) :
373 header_( header ),
374 samples_( samples ),
375 index_( index ),
376 set_( set )
377 {
378 }
379 
380 
381 inline
383 {
384 }
385 
386 
389 {
390  if ( this != &rhs )
391  header_ = rhs.header_;
392 
393  return *this;
394 }
395 
396 
397 inline carma::monitor::tagIDType
399 {
400  return header_.tagID;
401 }
402 
403 
404 inline ushort
406 {
407  return header_.sampleOffset;
408 }
409 
410 
411 inline ushort
413 {
414  return header_.nSamples;
415 }
416 
417 
419 carma::monitor::MonitorPointHeader::getValueType( ) const
420 {
421  return header_.getValueType();
422 }
423 
424 
425 inline void
426 carma::monitor::MonitorPointHeader::setValueType( const MonitorValueType mvt )
427 {
428  header_.setValueType( mvt );
429 }
430 
431 
433 carma::monitor::MonitorPointHeader::getMonitorSampleValueRef(
434  const int iSample ) const
435 {
436  return samples_[ header_.sampleOffset + iSample ];
437 }
438 
439 
441 carma::monitor::MonitorPointHeader::getMonitorSampleValueRef(
442  const int iSample )
443 {
444  return samples_[ header_.sampleOffset + iSample ];
445 }
446 
447 
449 carma::monitor::MonitorPointHeader::getAverageMonitorSampleValueRef( ) const
450 {
451  return samples_[ header_.sampleOffset ];
452 }
453 
454 
456 carma::monitor::MonitorPointHeader::getAverageMonitorSampleValueRef( )
457 {
458  return samples_[ header_.sampleOffset ];
459 }
460 
461 
464 {
465  return MonitorPointSample( samples_[ header_.sampleOffset + iSample ],
466  index_,
467  set_);
468 }
469 
470 
473 {
474  return MonitorPointSample( samples_[ header_.sampleOffset ],
475  index_,
476  set_ );
477 }
478 
479 
480 #endif // CARMA_MONITOR_MONITOR_POINT_HEADER_H
void setSamplesPerCycle(const ushort nSamples)
sets the the filed &quot;nSamples&quot; in the MonitorHeader struct. Meant for use by other classes in this fil...
short MonitorValueType
Enumeration of possible types for monitor point values.
void setSampleOffset(const ushort sampleOffset)
sets a reference to the set of sampled data associated with the monitor point. For use by Frame metho...
void setNumSamplesPerCycle(const ushort nSamples)
sets the number of samples per sampling cycle - which is currently standardized at half-second...
Class representing a data sample for a MonitorPoint.
tagIDType getTagID() const
gets the unique tagID for a monitor point.
A class that manages the sets of monitor points for a monitor subsystem.
void clearSamples(bool deallocate=false)
clears all the samples associated with this header.
Structure for storing monitor point sample, including value.
MonitorPointSample getMonitorPointSample(int iSample)
gets the ith sample from the set of sampled monitor values associated with the monitor point...
MonitorPointHeader & operator=(const MonitorPointHeader &rhs)
operator for assigning values to a MonitorPointHeader.
MonitorPointSample getSampleAverage()
gets the value of sampled data averaged over all monitor point samples that contain filled up data...
Class wrapper for monitor point samples stored in a subsystem frame.
MonitorPointHeader(MonitorHeader &header, MonitorSampleValue *samples, int index=-1, MonitorPointSet *set=0)
public constructor to build MonitorPointHeader object. Requires reference to a MonitorHeader structur...
ushort getNumSamplesPerCycle() const
gets the number of samples per sampling cycle - which is currently standardized at half-second...
type definitions for monitor system
ushort getSampleOffset() const
gets a reference to the set of sampled data associated with the monitor point.
Wrapper class for monitor point header information.