CARMA C++
MonitorDescription.h
1 
9 #ifndef CARMA_DBMS_MONITORDESCRIPTION_H
10 #define CARMA_DBMS_MONITORDESCRIPTION_H
11 
12 #include <string>
13 #include <map>
14 
15 #include "carma/corba/corba.h"
17 #include "carma/monitor/types.h"
18 #include "carma/util/Time.h"
19 
20 
21 namespace carma {
22  namespace dbms {
23 
24 
30  public:
31 
42  MonitorDescription(const std::string& canonicalName,
43  const MonitorPointType& mpType,
44  const MonitorPointDataType& dataType,
45  const bool& persistent, const unsigned& updateInterval,
46  const bool& spectrum);
47 
48  virtual ~MonitorDescription() {}
49 
53  inline void setShortName(const std::string& shortName) {
54  shortName_ = shortName;
55  }
56 
57  inline void setLongName(const std::string& longName) {
58  longName_ = longName;
59  }
60 
61  inline void setUnits(const std::string& units) { units_ = units; }
62 
63  inline void setDescription(const std::string& description) {
64  description_ = description;
65  }
66 
67  /*
68  inline void setIntegrateFunction(const std::string& integrateFunction) {
69  integrateFunction_ = integrateFunction;
70  }
71  */
72 
78  inline void setTime(const carma::util::frameType& frameCount) {
79  time_ = frameCount;
80  }
81 
82 
83  /*
84  void setWarnLo(const char* warnLo);
85  void setWarnHi(const char* warnHi);
86  void setWarnHi(const float& warnHi);
87  void setErrLo(const char* errLo);
88  void setErrLo(const float& errLo);
89  void setErrHi(const char* errHi);
90  void setErrHi(const float& errHi);
91  */
92 
97  (const carma::monitor::ThresholdValueEnum& thresholdType,
98  const double& value);
99 
100  double getThresholdValue
101  (const carma::monitor::ThresholdValueEnum& thresholdType) const;
102 
109  (const carma::monitor::ThresholdValueEnum& thresholdType) const;
110 
116  (const carma::monitor::ThresholdValueEnum& thresholdType) const;
117 
118 
123  inline std::string getSubsystemName() const {
124  return subsystemName_;
125  }
126 
131  inline std::string getName() const { return cname_;}
132 
137  std::string getShortName() const { return shortName_; }
138 
143  inline std::string getLongName() const { return longName_; }
144 
149  inline std::string getUnits() const { return units_; }
150 
155  inline int getUpdateInterval() const { return updateInterval_; }
156 
161  inline std::string getDescription() const {
162  return description_;
163  }
164 
171  return monitorPointType_;
172  }
173 
174  inline MonitorPointDataType getDataType() const { return dataType_; }
175 
180  inline bool isPersistent() const { return persistent_; }
181 
186  inline bool isSpectrum() const { return spectrum_; }
187 
188 
193  inline std::string getIntegrateFunction() const {
194  return integrateFunction_;
195  }
196 
202  return time_;
203  }
204 
208  std::string toString() const;
209 
216  bool isEqualExceptForTime(const MonitorDescription& md) const;
217 
225  void addEnumerator(const std::string& enumerator,
226  const std::string& description = "");
227 
237  void setEnumeratorDescription(const std::string& enumerator,
238  const std::string& description = "");
239 
246  std::vector<std::string> getEnumerators() const;
247 
254  std::map<std::string,std::string> getEnumeratorDescriptions() const;
255 
256  inline void setLocation(const std::string& location) {
257  location_ = location;
258  }
259 
260  inline std::string getLocation() const { return location_; }
261 
262  inline void setDevice(const std::string& device) { device_ = device; }
263 
264  inline std::string getDevice() const { return device_; }
265 
273  bool areStaticFieldsEqual(const MonitorDescription& other,
274  std::string& msg) const;
275 
287  void makeStaticChangedString(std::ostringstream &ss,
288  const std::string &fieldName,
289  const std::string &oldValue,
290  const std::string &newValue)const;
291 
292  void makeStaticChangedString(std::ostringstream &ss,
293  const char *fieldName,
294  const std::string &oldValue,
295  const std::string &newValue)const;
296 
297 #if 0
298 
302  MonitorDescription MonitorDescription::makeCopy(
303  const std::string &canonicalName,
304  carma::util::frameType time=0)const;
305 #endif
306 
307 private:
308 
309  MonitorPointType monitorPointType_; // type of monitor point
310 
311  // canonical name of the point
312  std::string cname_;
313  std::string subsystemName_; // subsystem name
314 
315  MonitorPointDataType dataType_;
316 
317  // location and device name for the point. Only matters for sense points
318  std::string location_;
319  std::string device_;
320 
321 
322  int updateInterval_;
323  bool persistent_;
324  bool spectrum_;
325 
326  /* elements of a monitor point */
327  // brief name to use as part of compact display
328  std::string shortName_;
329  // longer name/statement suitable for tooltip display
330  std::string longName_;
331  // measurement units for values of this point
332  std::string units_;
333 
334  // full description
335  std::string description_;
336 
337  // name of fctn to use to integrate point over some time interval
338  std::string integrateFunction_;
339 
340  //time at which the description became valid
342 
343  // for points of type DATATYPE_ENUMERATION, this is where the enumerator
344  // values are held, it maps enumerator values to their descriptions
345  std::vector<std::string> enumeratorNames_;
346  std::map<std::string,std::string> enumeratorDescriptions_;
347 
348 
349  /* warnings/errors are ignored unless point is a numeric type */
350 
351  /*
352  * the default values of the thresholds are stored as NULLs in the
353  * database. This class converts to a default double based on
354  * the monitor point type. to know if the value in the db is null,
355  * use the isDefaultThreshold() method.
356  */
357 
358  double warnLo_;
359  double warnHi_;
360  double errLo_;
361  double errHi_;
362 
363  bool isDefaultWarnLo_;
364  bool isDefaultWarnHi_;
365  bool isDefaultErrLo_;
366  bool isDefaultErrHi_;
367 
368  }; // end class
369  }; // end namespace dbms
370 }; // end namespace carma
371 
372 #endif
MonitorPointType getMonitorPointType() const
get the monitor point type
std::string getDescription() const
get the monitor point description
Common time functions.
bool isEqualExceptForTime(const MonitorDescription &md) const
are all fields in the specified description, except perhaps for the time_ field, equal to the fields ...
std::map< std::string, std::string > getEnumeratorDescriptions() const
get enumerator descriptions
void setTime(const carma::util::frameType &frameCount)
set the frame count for which this description became valid
std::string getName() const
get the canonical name of the monitor point
unsigned int frameType
Half second frames since Jan 1, 2000.
Definition: types.h:29
bool isPersistent() const
is the point persistent?
void setEnumeratorDescription(const std::string &enumerator, const std::string &description="")
add set an enumerators description, unlike addEnumerator, this method should only be called on an exi...
A MonitorDescription object holds all information on a monitor point which is stored in the database ...
relationships between the monitor and dbms systems
int getUpdateInterval() const
get the update interval
bool areStaticFieldsEqual(const MonitorDescription &other, std::string &msg) const
are the static fields of this monitor description the same as the specified description?
std::string getLongName() const
get the long name
std::string toString() const
produce a string representation of the monitor point description
bool isSpectrum() const
does the point represent a spectrum?
bool isDefaultThresholdValue(const carma::monitor::ThresholdValueEnum &thresholdType) const
is the specified threshold value the default value, ie, is the specified threshold value stored as NU...
std::string getShortName() const
get the short name
void addEnumerator(const std::string &enumerator, const std::string &description="")
add an enumerator and its description
std::string getSubsystemName() const
get the subystem name to which this point belongs
MonitorPointType
describes to what class this monitor point belongs
double getThresholdDefaultValue(const carma::monitor::ThresholdValueEnum &thresholdType) const
get the default value for the specified threshold.
carma::util::frameType getTime() const
get the frame count for which this description became valid
std::vector< std::string > getEnumerators() const
get enumerators names
type definitions for monitor system
void setThresholdValue(const carma::monitor::ThresholdValueEnum &thresholdType, const double &value)
set the value of the low warning threshold.
void setShortName(const std::string &shortName)
set short name
void makeStaticChangedString(std::ostringstream &ss, const std::string &fieldName, const std::string &oldValue, const std::string &newValue) const
Create the string describing what static field for which a changed had been attempted.
MonitorDescription(const std::string &canonicalName, const MonitorPointType &mpType, const MonitorPointDataType &dataType, const bool &persistent, const unsigned &updateInterval, const bool &spectrum)
constructor
std::string getUnits() const
get the units
std::string getIntegrateFunction() const
get the name of the function used to integrate (average) the half-second data
MonitorPointDataType
type of the monitor point.