CARMA C++
MonitorPointSample.h
Go to the documentation of this file.
1 
12 #ifndef CARMA_MONITOR_MONITOR_POINT_SAMPLE_H
13 #define CARMA_MONITOR_MONITOR_POINT_SAMPLE_H
14 
15 #include <string>
16 
17 #include "carma/corba/corba.h"
19 #include "carma/monitor/monitorframe.h"
20 #include "carma/monitor/types.h"
21 
22 namespace carma {
23 
24 namespace monitor {
25 
26 struct TransportMonitorValue;
27 struct TransportMonitorSample;
28 
36 typedef union {
37  uchar byte;
38  short sh;
39  long lo;
40  bool bo;
41  float fl;
42  double db;
43  float complex[2];
44  char str[8];
45  long sn;
46 } MonitorValue; // 8 bytes
47 
56  MonitorValue value;
57  uchar blankingFlags;
58  uchar validityFlags;
59  uchar iSample;
60  uchar dummy;
61 
62  uchar getValidityFlags( ) const;
63  uchar getBlankingFlags( ) const;
64 }; // 12 bytes
65 
66 
67 struct MonitorValueStringChunk {
68  char chunkChars[8];
69 };
70 
71 
72 class MonitorPointSet;
73 
80  public:
96  explicit MonitorPointSample( MonitorSampleValue & sample,
97  int index = -1,
98  MonitorPointSet * set = 0 );
99 
104 
111  MonitorValue & getMonitorValue () const;
112 
120  uchar saneFlags );
128  uchar saneFlags );
129 
137  uchar saneFlags );
138 
146  uchar saneFlags );
147 
155  uchar saneFlags );
156 
163  void setMonitorValueAndKnownSaneValidityFlags( double value,
164  uchar saneFlags );
165 
172  void setMonitorValueAndKnownSaneValidityFlags( const float value[2],
173  uchar saneFlags );
174 
183  const MonitorValueStringChunk & value,
184  uchar saneFlags );
185 
193  uchar saneFlags );
194 
204  uchar getBlankingFlags( ) const;
205 
215  void setBlankingFlags( uchar flags );
216 
224  void clearBlankingFlags( );
225 
234  ushort getSampleNumber( ) const;
235 
244  void setSampleNumber( ushort iSample );
245 
255  uchar getValidityFlags( ) const ;
256 
268  void setValidityFlags( uchar flags );
269 
270  void setKnownSaneValidityFlags( uchar saneFlags,
271  bool markMpAsModified = true );
272 
280  void clearValidityFlags ();
281 
292  void clearFlags ();
293 
305 
323  void allocate (ushort headerOffset, ushort iSample);
324 
332  void clear (bool deallocate = false);
333 
340  MonitorSampleValue & getSample( ) const;
341 
356  void fillInTransportSample( CORBA::ULong metaIdx,
357  MonitorSampleValues & outSamples,
358  MonitorValueType mvt,
359  tagIDType tagId,
360  int sampleIndex ) const;
382  void getTransportedSample( CORBA::ULong metaIdx,
383  const MonitorSampleValues & inValues,
384  int headerOffset );
385 
397  void setTransportValue(MonitorValueType valueType,
398  TransportMonitorValue& value ) const;
399 
400  protected:
410  MonitorValue & getValue( ) const;
411 
412  private:
414  const MonitorValue & value,
415  uchar saneFlags );
416 
428  void getTransportedValue( MonitorValueType valueType,
429  const TransportMonitorValue & value );
430 
431 
432  // MonitorSampleValue structure in subsystem frame container.
433  MonitorSampleValue & sample_;
434 
435  // index to monitor point header in containing subsystem frame
436  const int index_;
437 
438  // pointer to containing MonitorPointSet
439  MonitorPointSet * const set_;
440 };
441 
442 
443 
454  public:
455  explicit SampleInvalidExceptionObj(
456  const char * mesg,
457  const char * fileName = __FILE__,
458  int lineNum = __LINE__ );
459 
460  explicit SampleInvalidExceptionObj(
461  const std::ostringstream & errStream,
462  const char * fileName = __FILE__,
463  int lineNum = __LINE__ );
464 
466  const MonitorSampleValue & sample,
467  MonitorValueType type,
468  const char * fileName = __FILE__,
469  int lineNum = __LINE__ );
470 
472  const MonitorPointSample & sample,
473  MonitorValueType type,
474  const char * fileName = __FILE__,
475  int lineNum = __LINE__ );
476 };
477 
478 } } // namespace monitor, carma
479 
480 
481 inline carma::monitor::uchar
482 carma::monitor::MonitorSampleValue::getValidityFlags( ) const
483 {
484  return validityFlags;
485 }
486 
487 
488 inline carma::monitor::uchar
489 carma::monitor::MonitorSampleValue::getBlankingFlags( ) const
490 {
491  return blankingFlags;
492 }
493 
494 
495 inline
497  MonitorSampleValue & sample,
498  const int index,
499  MonitorPointSet * const set ) :
500 sample_( sample ),
501 index_( index ),
502 set_( set )
503 {
504 }
505 
506 
507 inline
509 {
510 }
511 
512 
515 {
516  if ( this != &rhs ) {
517  sample_.value = rhs.sample_.value;
518  sample_.blankingFlags = rhs.sample_.blankingFlags;
519  sample_.validityFlags = rhs.sample_.validityFlags;
520  }
521 
522  return *this;
523 }
524 
525 
528 {
529  return sample_.value;
530 }
531 
532 
533 inline carma::monitor::uchar
535 {
536  return sample_.validityFlags;
537 }
538 
539 
540 inline carma::monitor::uchar
542 {
543  return sample_.blankingFlags;
544 }
545 
546 
547 inline unsigned short
549 {
550  return sample_.iSample;
551 }
552 
553 
554 inline void
556 {
557  sample_.iSample = iSample;
558 }
559 
560 
563 {
564  return sample_;
565 }
566 
567 
570 {
571  return sample_.value;
572 }
573 
574 
575 inline void
577 {
578  sample_.blankingFlags = flags;
579 }
580 
581 
582 inline void
584 {
585  sample_.blankingFlags = 0;
586 }
587 
588 
589 inline void
591 {
592  sample_.validityFlags = 0;
593 }
594 
595 
596 inline void
598 {
599  sample_.blankingFlags = 0;
600  sample_.validityFlags = 0;
601 }
602 
603 
604 inline void
606 {
607  sample_.blankingFlags = 0;
608  sample_.validityFlags = 0;
609 
610  if ( deallocate ) {
611  sample_.dummy = 0;
612  sample_.iSample = 0;
613  }
614 }
615 
616 
617 inline void
619  const ushort iSample )
620 {
621  sample_.blankingFlags = 0;
622  sample_.validityFlags = 0;
623  sample_.dummy = (headerOffset & 0x00FF);
624  sample_.iSample = iSample;
625 }
626 
627 
628 #endif // CARMA_MONITOR_MONITOR_POINT_SAMPLE_H
short MonitorValueType
Enumeration of possible types for monitor point values.
ushort getSampleNumber() const
Method to return sample number asscoiated with this MonitorPointSample.
MonitorPointSample & operator=(const MonitorPointSample &rhs)
Assignment operator.
This is the include file for Carma exception handling utilities.
Class representing a data sample for a MonitorPoint.
void setValueStringChunkAndKnownSaneValidityFlags(const MonitorValueStringChunk &value, uchar saneFlags)
Method to set monitor sample value as a string chunk and already &quot;sane&quot; validity flags at the same...
A class that manages the sets of monitor points for a monitor subsystem.
MonitorValue & getMonitorValue() const
Method to get monitor sample value as a union.
MonitorValue & getValue() const
Returns internal union structure containingv the value of the monitor point sample.
uchar getValidityFlags() const
Method to return validity flag value of the monitor sample.
void clear(bool deallocate=false)
Clears all flags and (optionally) deallocates the sample so the sample is no longer associated with a...
void setSampleNumber(ushort iSample)
Method to set sample number associated with this MonitorPointSample.
void allocate(ushort headerOffset, ushort iSample)
Associates this sample with a monitor point represented by a MonitorPointHeader at offset headerOffse...
void getTransportedSample(CORBA::ULong metaIdx, const MonitorSampleValues &inValues, int headerOffset)
This method and MonitorPointSample::fillInTransportSample are transport related methods.
MonitorPointSample(MonitorSampleValue &sample, int index=-1, MonitorPointSet *set=0)
Constructor - takes the base level structure, index to the corresponding monitor point&#39;s header infor...
Structure for storing monitor point sample, including value.
void clearBlankingFlags()
Method to clear blanking flag value of the monitor sample.
void clearFlags()
Method to clear validity and blanking/flagging flag values of the monitor sample. ...
Base exception class for managing carma errors.
Definition: BaseException.h:48
Exception class thrown when an invalid sample is detected.
uchar getBlankingFlags() const
Method to return blanking flag value of the monitor sample.
void setValueSerialNoAndKnownSaneValidityFlags(long value, uchar saneFlags)
Method to set monitor sample value as a serial number.
MonitorSampleValue & getSample() const
Returns a reference to the internal MonitorSampleValue structure.
type definitions for monitor system
void setTransportValue(MonitorValueType valueType, TransportMonitorValue &value) const
Sets monitor point sample value to be transported using value from this sample.
void setBlankingFlags(uchar flags)
Method to set blanking flag value of the monitor sample.
Union of all possible types of monitor sample values.
void clearValidityFlags()
Method to clear validity flag value of the monitor sample.
void setValidityFlags(uchar flags)
Method to set validity flag value of the monitor sample.
void setMonitorValueAndKnownSaneValidityFlags(char value, uchar saneFlags)
Method to set monitor sample value as a char.
void fillInTransportSample(CORBA::ULong metaIdx, MonitorSampleValues &outSamples, MonitorValueType mvt, tagIDType tagId, int sampleIndex) const
This method and MonitorPointSample:;getTransportedSample are transport related methods.