CARMA C++
CanMonitorPoint.h
Go to the documentation of this file.
1 #ifndef SZA_ANTENNA_CANBUS_CANMONITORPOINT_H
2 #define SZA_ANTENNA_CANBUS_CANMONITORPOINT_H
3 
12 #include "carma/szaarrayutils/regmap.h"
13 #include "carma/szautil/DataType.h"
14 
15 #define CAN_MONITOR_CONDITION_HANDLER(fn) void (fn)(void* arg, bool satisfied, std::string message)
16 
17 namespace sza {
18 
19  namespace util {
20  class Coord;
21  class CoordRange;
22  }
23 
24  namespace antenna {
25 
26  namespace control {
27  class SzaShare;
28  }
29 
30  namespace canbus {
31 
32  class CanMonitorPoint {
33  public:
34 
38  CanMonitorPoint(sza::antenna::control::SzaShare* share,
39  RegMapBlock* block);
40 
44  virtual ~CanMonitorPoint();
45 
46  inline RegMapBlock* block() {
47  return block_;
48  }
49 
50  void writeReg(bool isSim, bool b, sza::util::CoordRange* range=0);
51  void writeReg(bool isSim, unsigned char uc, sza::util::CoordRange* range=0);
52  void writeReg(bool isSim, char ch, sza::util::CoordRange* range=0);
53  void writeReg(bool isSim, unsigned short us, sza::util::CoordRange* range=0);
54  void writeReg(bool isSim, short s, sza::util::CoordRange* range=0);
55  void writeReg(bool isSim, unsigned int ui, sza::util::CoordRange* range=0);
56  void writeReg(bool isSim, int i, sza::util::CoordRange* range=0);
57  void writeReg(bool isSim, float f, sza::util::CoordRange* range=0);
58  void writeReg(bool isSim, double d, sza::util::CoordRange* range=0);
59 
60  void writeReg(bool isSim, bool* b, sza::util::CoordRange* range=0);
61  void writeReg(bool isSim, unsigned char* uc, sza::util::CoordRange* range=0);
62  void writeReg(bool isSim, char* ch, sza::util::CoordRange* range=0);
63  void writeReg(bool isSim, unsigned short* us, sza::util::CoordRange* range=0);
64  void writeReg(bool isSim, short* s, sza::util::CoordRange* range=0);
65  void writeReg(bool isSim, unsigned int* ui, sza::util::CoordRange* range=0);
66  void writeReg(bool isSim, int* i, sza::util::CoordRange* range=0);
67  void writeReg(bool isSim, float* f, sza::util::CoordRange* range=0);
68  void writeReg(bool isSim, double* d, sza::util::CoordRange* range=0);
69 
70  // Register a callback associated with a condition
71 
72  void registerConditionHandler(CAN_MONITOR_CONDITION_HANDLER(*handler),
73  void* arg,
74  std::string& message,
75  CanMonitorCondition& condition,
76  sza::util::Coord* coord=0);
77 
78  // This struct will manage condition-handler associations.
79 
80  struct ConditionHandler {
81  CanMonitorCondition condition_;
82  CAN_MONITOR_CONDITION_HANDLER(*handler_);
83  void* arg_;
84  std::string message_;
85 
86  unsigned packetCount_;
87  unsigned stablePacketCount_;
88  unsigned giveUpPacketCount_;
89 
90  ConditionHandler();
91  void callHandler(bool conditionWasMet);
92  };
93 
94  private:
95 
96  // The register block that represents this monitor point
97 
98  RegMapBlock* block_;
99 
100  // A pointer to the shared memory object
101 
103 
104  // The value of this monitor point
105 
106  sza::util::DataType dataType_;
107 
108  // A vector of handlers
109 
110  std::vector<ConditionHandler> handlers_;
111 
115  void checkHandler(bool isSim, sza::util::CoordRange* range);
116 
117  }; // End class CanMonitorPoint
118 
119  } // End namespace canbus
120  } // End namespace antenna
121 } // End namespace sza
122 
123 
124 #endif // End #ifndef SZA_ANTENNA_CANBUS_CANMONITORPOINT_H
Tagged: Tue Jun 22 22:32:16 UTC 2004.
A class for specifying a coordinate in a multi-dimensional space.
Definition: Coord.h:21
An instance of this class is created by AntennaMaster and passed to the constructors of other tasks...
Definition: Share.h:38
Tagged: Sun Oct 24 17:05:09 PDT 2004.
Enumerate data types.
Definition: DataType.h:28