CARMA C++
RemoteSensor.h
Go to the documentation of this file.
1 // $Id: RemoteSensor.h,v 1.4 2011/08/01 18:14:35 eml Exp $
2 
3 #ifndef SZA_UTIL_REMOTESENSOR_H
4 #define SZA_UTIL_REMOTESENSOR_H
5 
19 #include "carma/szautil/Temperature.h"
20 #include "carma/szautil/Time.h"
21 #include "carma/szautil/TimeOut.h"
22 #include "carma/szautil/TimeVal.h"
23 
24 #include "carma/monitor/SystemStatus.h"
26 
27 #include <string>
28 
29 namespace sza {
30  namespace util {
31 
32  //-----------------------------------------------------------------------
33  // A utility class for sending messages to the RemoteSensorCoProc task
34  //-----------------------------------------------------------------------
35 
36  class RemoteSensorMsg : public GenericTaskMsg {
37  public:
38 
39  enum MsgType {
40  READ_SENSOR,
41  };
42 
43  union {
44  bool enable;
45  } body;
46 
47  // A type for this message
48 
49  MsgType type;
50  };
51 
52  //-----------------------------------------------------------------------
53  // RemoteSensor class definition
54  //-----------------------------------------------------------------------
55 
56  class RemoteSensor : public SpawnableTask<RemoteSensorMsg> {
57 
58  public:
59 
63  RemoteSensor(std::string host,
64  unsigned timeoutIntervalInSeconds=0);
65 
66  RemoteSensor(std::string host,
67  SystemStatusSubsystemMutex* ms,
68  carma::monitor::MonitorPointBool& mpIsReachable,
69  carma::monitor::MonitorPointDouble& mpCurrentTemperature,
70  unsigned timeoutIntervalInSeconds=0);
71 
72  RemoteSensor(std::string host,
73  SystemStatusSubsystemMutex* ms,
74  carma::monitor::MonitorPointBool& mpHostIsReachable,
77  carma::monitor::MonitorPointEnum& mpPlaceStatus,
79  carma::monitor::MonitorPointDouble& mpCurrentTemperature,
80  sza::util::Temperature& minTemp,
81  sza::util::Temperature& maxTemp,
82  unsigned timeoutIntervalInSeconds=0);
83 
84  void initialize(std::string host, unsigned timeoutIntervalInSeconds,
85  SystemStatusSubsystemMutex* ms);
86 
90  virtual ~RemoteSensor();
91 
92  void readSensor();
93 
94  virtual void printTemps();
95 
96  protected:
97 
98  Time deltaSampleTime_;
99  TimeVal lastSampleTime_;
100  bool firstSample_;
101 
102  std::string host_;
103  Temperature currentTemp_;
104  Temperature lastTemp_;
105  Temperature minTemp_;
106  Temperature maxTemp_;
107  TimeOut timeOut_;
108 
109  bool haveMonitorSystem_;
110 
111  SystemStatusSubsystemMutex* ms_;
112  carma::monitor::MonitorPointBool* mpHostIsReachable_;
114  carma::monitor::MonitorPointBool* mpPlaceIsOk_;
115  carma::monitor::MonitorPointEnum* mpPlaceStatus_;
116  carma::monitor::MonitorPointDouble* mpCurrentTemperature_;
118 
119  // Run method for this object
120 
121  void serviceMsgQ();
122 
123  // Set up our internal timeout
124 
125  void initializeTimeout(unsigned timeoutIntervalInSeconds);
126 
127  // Process a request to read the sensor
128 
129  void processReadSensorMsg();
130 
131  // Generic method to process messages received on our queue
132 
133  void processMsg(RemoteSensorMsg* msg);
134 
135  // Inheritors should define what it means to read a particular
136  // sensor
137 
138  virtual void executeReadSensor() = 0;
139 
140  // Inheritors may define what it means to write monitor points
141  // for a particular sensor
142 
143  virtual void writeMonitorPoints(bool isReachable);
144 
145  }; // End class RemoteSensor
146 
147  } // End namespace util
148 } // End namespace sza
149 
150 
151 
152 #endif // End #ifndef SZA_UTIL_REMOTESENSOR_H
Classes that provide the pecializations of monitor points and sense poiints for different datatypes...
Tagged: Fri Nov 14 12:39:38 UTC 2003.
Abstract base class for any enumerated constants, like state machines.
Tagged: Fri Nov 14 12:39:34 UTC 2003.
Tagged: Wed Jul 13 13:56:11 PDT 2011.
Tagged: Mon Jul 19 14:47:35 PDT 2004.
Tagged: Tue May 2 16:31:46 PDT 2006.
Absolute time value monitor point.
Tagged: Fri Jan 26 16:49:57 NZDT 2007.