12 #ifndef CARMA_MONITOR_MONITORSYSTEMWITHTHRESHOLD_H
13 #define CARMA_MONITOR_MONITORSYSTEMWITHTHRESHOLD_H
46 carma::monitor::ThresholdValueEnum type);
55 carma::monitor::ThresholdValueEnum type);
64 carma::monitor::ThresholdValueEnum type);
72 std::vector<MonitorPointThreshold*>
80 MonitorPointThreshold&
getThreshold(
const std::string &mpName);
102 template <
typename T>
104 carma::monitor::ThresholdValueEnum type,
113 template <
typename T>
115 carma::monitor::ThresholdValueEnum type,
124 template <
typename T>
126 carma::monitor::ThresholdValueEnum type,
128 std::vector<carma::monitor::MonitorPointThreshold*> thresholds =
130 std::vector<carma::monitor::MonitorPointThreshold*>::iterator mpt;
131 std::vector<carma::monitor::MonitorPointThreshold*>::iterator thresholdsEnd =
134 for (mpt = thresholds.begin(); mpt != thresholdsEnd; mpt++) {
145 template <
typename T>
148 carma::monitor::ThresholdValueEnum type) {
149 struct we_should_not_be_here;
151 if (
sizeof( we_should_not_be_here ) != 3 )
159 carma::monitor::ThresholdValueEnum type) {
160 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
161 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BYTE) {
162 throw CARMA_ERROR(
"Monitor point value is not a char");
165 return threshold.getByteThresholdValue(type);
170 carma::monitor::ThresholdValueEnum type) {
171 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
172 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_SHORT) {
173 throw CARMA_ERROR(
"Monitor point value is not a short");
176 return threshold.getShortThresholdValue(type);
181 carma::monitor::ThresholdValueEnum type) {
182 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
183 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_INTEGER) {
184 throw CARMA_ERROR(
"Monitor point value is not a long");
187 return threshold.getLongThresholdValue(type);
192 carma::monitor::ThresholdValueEnum type) {
193 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
194 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BOOLEAN) {
195 throw CARMA_ERROR(
"Monitor point value is not a bool");
198 return threshold.getBoolThresholdValue(type);
203 carma::monitor::ThresholdValueEnum type) {
204 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
205 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_FLOAT) {
206 throw CARMA_ERROR(
"Monitor point value is not a float");
209 return threshold.getFloatThresholdValue(type);
214 carma::monitor::ThresholdValueEnum type) {
215 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
216 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_DOUBLE) {
217 throw CARMA_ERROR(
"Monitor point value is not a double");
220 return threshold.getDoubleThresholdValue(type);
225 carma::monitor::ThresholdValueEnum type) {
226 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
227 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_STRING) {
228 throw CARMA_ERROR(
"Monitor point value is not a string");
231 return threshold.getStringThresholdValue(type);
234 inline std::complex<float>
236 carma::monitor::ThresholdValueEnum type) {
237 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
238 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_COMPLEX) {
239 throw CARMA_ERROR(
"Monitor point value is not a complex");
242 return threshold.getComplexThresholdValue(type);
246 template <
typename T>
249 carma::monitor::ThresholdValueEnum type) {
250 struct we_should_not_be_here;
252 if (
sizeof( we_should_not_be_here ) != 3 )
260 carma::monitor::ThresholdValueEnum type) {
261 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BYTE) {
262 throw CARMA_ERROR(
"Monitor point value is not a char");
265 return threshold.getByteThresholdValue(type);
270 carma::monitor::ThresholdValueEnum type) {
271 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_SHORT) {
272 throw CARMA_ERROR(
"Monitor point value is not a short");
275 return threshold.getShortThresholdValue(type);
280 carma::monitor::ThresholdValueEnum type) {
281 if (threshold.getValueType() == carma::monitor::MONITOR_VALUE_TYPE_INTEGER) {
282 return threshold.getLongThresholdValue(type);
283 }
else if (threshold.getValueType() == carma::monitor::MONITOR_VALUE_TYPE_SERIAL_NUMBER) {
284 return threshold.getSerialNoThresholdValue(type);
286 throw CARMA_ERROR(
"Monitor point value is not a long or serial number");
293 carma::monitor::ThresholdValueEnum type) {
294 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BOOLEAN) {
295 throw CARMA_ERROR(
"Monitor point value is not a bool");
298 return threshold.getBoolThresholdValue(type);
303 carma::monitor::ThresholdValueEnum type) {
304 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_FLOAT) {
305 throw CARMA_ERROR(
"Monitor point value is not a float");
308 return threshold.getFloatThresholdValue(type);
314 carma::monitor::ThresholdValueEnum type) {
315 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_DOUBLE) {
316 throw CARMA_ERROR(
"Monitor point value is not a double");
319 return threshold.getDoubleThresholdValue(type);
324 carma::monitor::ThresholdValueEnum type) {
325 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_STRING) {
326 throw CARMA_ERROR(
"Monitor point value is not a string");
329 return threshold.getStringThresholdValue(type);
332 inline std::complex<float>
334 carma::monitor::ThresholdValueEnum type) {
335 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_COMPLEX) {
336 throw CARMA_ERROR(
"Monitor point value is not a complex");
339 return threshold.getComplexThresholdValue(type);
343 template <
typename T>
346 carma::monitor::ThresholdValueEnum type) {
348 std::vector<T> values;
351 std::vector<std::string> monitorPointNames;
354 std::vector<std::string>::iterator nameIterator;
355 std::vector<std::string>::iterator monitorPointNamesEnd = monitorPointNames.end();
357 for (nameIterator = monitorPointNames.begin();
358 nameIterator != monitorPointNamesEnd;
360 values.push_back(getThresholdValue<T>(*nameIterator, type));
367 template <
typename T>
370 carma::monitor::ThresholdValueEnum type,
372 struct we_should_not_be_here;
374 if (
sizeof( we_should_not_be_here ) != 3 )
382 carma::monitor::ThresholdValueEnum type,
384 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
385 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BYTE) {
386 throw CARMA_ERROR(
"Monitor point value is not a char");
389 threshold.setRangeValue(type, value);
394 carma::monitor::ThresholdValueEnum type,
396 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
397 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_SHORT) {
398 throw CARMA_ERROR(
"Monitor point value is not a short");
401 threshold.setRangeValue(type, value);
406 carma::monitor::ThresholdValueEnum type,
408 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
409 if (threshold.getValueType() == carma::monitor::MONITOR_VALUE_TYPE_INTEGER) {
410 threshold.setRangeValue(type, value);
411 }
else if (threshold.getValueType() == carma::monitor::MONITOR_VALUE_TYPE_SERIAL_NUMBER) {
412 threshold.setRangeValueSerialNo(type, value);
414 throw CARMA_ERROR(
"Monitor point value is not an integer (long) or serial number");
420 carma::monitor::ThresholdValueEnum type,
422 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
423 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BOOLEAN) {
424 throw CARMA_ERROR(
"Monitor point value is not a bool");
427 threshold.setRangeValue(type, value);
432 carma::monitor::ThresholdValueEnum type,
434 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
435 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_FLOAT) {
436 throw CARMA_ERROR(
"Monitor point value is not a float");
439 threshold.setRangeValue(type, value);
444 carma::monitor::ThresholdValueEnum type,
446 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
447 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_DOUBLE) {
448 throw CARMA_ERROR(
"Monitor point value is not a double");
451 threshold.setRangeValue(type, value);
456 carma::monitor::ThresholdValueEnum type,
457 std::complex<float> value) {
458 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
459 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_COMPLEX) {
460 throw CARMA_ERROR(
"Monitor point value is not a complex");
463 threshold.setRangeValue(type, value);
468 carma::monitor::ThresholdValueEnum type,
470 carma::monitor::MonitorPointThreshold threshold =
getThreshold(mpName);
471 if (threshold.getValueType() != carma::monitor::MONITOR_VALUE_TYPE_STRING) {
472 throw CARMA_ERROR(
"Monitor point value is not a string");
475 threshold.setRangeValue(type, value);
479 template <
typename T>
482 carma::monitor::ThresholdValueEnum type,
484 struct we_should_not_be_here;
486 if (
sizeof( we_should_not_be_here ) != 3 )
494 carma::monitor::ThresholdValueEnum type,
496 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BYTE) {
497 throw CARMA_ERROR(
"Monitor point value is not a char");
500 threshold->setRangeValue(type, value);
505 carma::monitor::ThresholdValueEnum type,
507 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_SHORT) {
508 throw CARMA_ERROR(
"Monitor point value is not a short");
511 threshold->setRangeValue(type, value);
516 carma::monitor::ThresholdValueEnum type,
518 if (threshold->getValueType() == carma::monitor::MONITOR_VALUE_TYPE_INTEGER) {
519 threshold->setRangeValue(type, value);
520 }
else if (threshold->getValueType() == carma::monitor::MONITOR_VALUE_TYPE_SERIAL_NUMBER) {
521 threshold->setRangeValueSerialNo(type, value);
523 throw CARMA_ERROR(
"Monitor point value is not an integer (long) or serial number");
529 carma::monitor::ThresholdValueEnum type,
531 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_BOOLEAN) {
532 throw CARMA_ERROR(
"Monitor point value is not a bool");
535 threshold->setRangeValue(type, value);
540 carma::monitor::ThresholdValueEnum type,
542 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_FLOAT) {
543 throw CARMA_ERROR(
"Monitor point value is not a float");
546 threshold->setRangeValue(type, value);
551 carma::monitor::ThresholdValueEnum type,
553 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_DOUBLE) {
554 throw CARMA_ERROR(
"Monitor point value is not a double");
557 threshold->setRangeValue(type, value);
562 carma::monitor::ThresholdValueEnum type,
563 std::complex<float> value) {
564 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_COMPLEX) {
565 throw CARMA_ERROR(
"Monitor point value is not a complex");
568 threshold->setRangeValue(type, value);
573 carma::monitor::ThresholdValueEnum type,
575 if (threshold->getValueType() != carma::monitor::MONITOR_VALUE_TYPE_STRING) {
576 throw CARMA_ERROR(
"Monitor point value is not a string");
579 threshold->setRangeValue(type, value);
std::vector< std::string > getMonitorPointNames(const std::string &searchString)
method for obtaining monitor point names
MonitorSystemWithThreshold is a class that contains methods for retrieving and setting threshold valu...
std::vector< T > getThresholdValues(const std::string &searchString, carma::monitor::ThresholdValueEnum type)
method for obtaining threshold values
std::vector< MonitorPointThreshold * > getThresholds(const std::string &searchString)
method for obtaining threshold objects
T getThresholdValue(const std::string &mpName, carma::monitor::ThresholdValueEnum type)
method for obtaining threshold value for a particular MP
Monitor system base class.
MonitorPointThreshold & getThreshold(const std::string &mpName)
method for obtaining threshold object for a particular MP
std::vector< std::string > getAllMonitorPointNames()
method for obtaining all monitor point names
void setThresholdValue(const std::string &mpName, carma::monitor::ThresholdValueEnum type, T value)
method for setting threshold value for a specific mp
Class that manages the IPQ version of SystemThresholdFrame.
#define CARMA_ERROR(y)
Trick to get the file name and line number passed to the exception handler.
void setThresholdValues(const std::string &searchString, carma::monitor::ThresholdValueEnum type, T value)
method for setting threshold values for multiple monitor points using