CARMA C++
sanityChecks.h
1 #ifndef CARMA_MONITOR_SANITYCHECKS_H
2 #define CARMA_MONITOR_SANITYCHECKS_H
3 
5 #include "carma/monitor/types.h"
6 
7 
8 namespace carma {
9 namespace monitor {
10 
11 
12 void logBadValidityFlags( uchar vf,
13  const MonitorPoint * mp,
14  bool fix,
15  const char * context );
16 
17 void logBadValidityFlags( uchar vf,
18  tagIDType tagId,
19  int sampleIndex,
20  bool fix,
21  const char * context );
22 
23 void logBadValidity( MonitorPoint::VALIDITY validity,
24  const MonitorPoint * mp,
25  bool fix,
26  const char * context );
27 
28 
29 uchar sanityCheckValidityFlags( uchar vf,
30  const MonitorPoint * mp,
31  bool fix,
32  const char * context );
33 
34 uchar sanityCheckValidityFlags( uchar vf,
35  tagIDType tagId,
36  int sampleIndex,
37  bool fix,
38  const char * context );
39 
41 sanityCheckValidity( MonitorPoint::VALIDITY validity,
42  const MonitorPoint * mp,
43  bool fix,
44  const char * context );
45 
46 
47 } // namespace carma::monitor
48 } // namespace carma
49 
50 
51 inline carma::monitor::uchar
52 carma::monitor::sanityCheckValidityFlags(
53  const uchar vf,
54  const MonitorPoint * const mp,
55  const bool fix,
56  const char * const context )
57 {
58  if ( vf >= MonitorPoint::MAX_VALIDITY ) {
59  logBadValidityFlags( vf, mp, fix, context );
60 
61  if ( fix )
62  return MonitorPoint::INVALID_NO_DATA;
63  else
64  return vf;
65  } else
66  return vf;
67 }
68 
69 
70 inline carma::monitor::uchar
71 carma::monitor::sanityCheckValidityFlags(
72  const uchar vf,
73  const tagIDType tagId,
74  const int sampleIndex,
75  const bool fix,
76  const char * const context )
77 {
78  if ( vf >= MonitorPoint::MAX_VALIDITY ) {
79  logBadValidityFlags( vf, tagId, sampleIndex, fix, context );
80 
81  if ( fix )
82  return MonitorPoint::INVALID_NO_DATA;
83  else
84  return vf;
85  } else
86  return vf;
87 }
88 
89 
91 carma::monitor::sanityCheckValidity(
92  const MonitorPoint::VALIDITY validity,
93  const MonitorPoint * const mp,
94  const bool fix,
95  const char * const context )
96 {
97  if ( static_cast< uchar >( validity ) >= MonitorPoint::MAX_VALIDITY ) {
98  logBadValidity( validity, mp, fix, context );
99 
100  if ( fix )
101  return MonitorPoint::INVALID_NO_DATA;
102  else
103  return validity;
104  } else
105  return validity;
106 }
107 
108 
109 #endif
VALIDITY
Validity states of the data value.
Definition: MonitorPoint.h:132
Abstract base class for all monitor points.
type definitions for monitor system