Skip to content
Snippets Groups Projects
Commit e67842ba authored by Martin Killenberg's avatar Martin Killenberg
Browse files

StatusMonitor: simplified tests. MinMonitor, MaxMonitor and RangeMonitor all use >= and <=

parent 1df4749f
No related branches found
No related tags found
No related merge requests found
...@@ -67,9 +67,9 @@ namespace ChimeraTK { ...@@ -67,9 +67,9 @@ namespace ChimeraTK {
template<typename T> template<typename T>
struct MaxMonitor : public StatusMonitor<T> { struct MaxMonitor : public StatusMonitor<T> {
using StatusMonitor<T>::StatusMonitor; using StatusMonitor<T>::StatusMonitor;
/** WARNING state to be reported if threshold is crossed*/ /** WARNING state to be reported if threshold is reached or exceeded*/
ScalarPushInput<T> warning{this, "upperWarningThreshold", "", "", StatusMonitor<T>::_parameterTags}; ScalarPushInput<T> warning{this, "upperWarningThreshold", "", "", StatusMonitor<T>::_parameterTags};
/** ERROR state to be reported if threshold is crossed*/ /** ERROR state to be reported if threshold is reached or exceeded*/
ScalarPushInput<T> error{this, "upperErrorThreshold", "", "", StatusMonitor<T>::_parameterTags}; ScalarPushInput<T> error{this, "upperErrorThreshold", "", "", StatusMonitor<T>::_parameterTags};
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
...@@ -78,10 +78,10 @@ namespace ChimeraTK { ...@@ -78,10 +78,10 @@ namespace ChimeraTK {
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warning, error}; ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warning, error};
while(true) { while(true) {
// evaluate and publish first, then read and wait. This takes care of the publishing the initial variables // evaluate and publish first, then read and wait. This takes care of the publishing the initial variables
if(StatusMonitor<T>::oneUp.watch > error) { if(StatusMonitor<T>::oneUp.watch >= error) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(StatusMonitor<T>::oneUp.watch > warning) { else if(StatusMonitor<T>::oneUp.watch >= warning) {
StatusMonitor<T>::status = WARNING; StatusMonitor<T>::status = WARNING;
} }
else { else {
...@@ -108,10 +108,10 @@ namespace ChimeraTK { ...@@ -108,10 +108,10 @@ namespace ChimeraTK {
/** If there is a change either in value monitored or in thershold values, the status is re-evaluated*/ /** If there is a change either in value monitored or in thershold values, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warning, error}; ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warning, error};
while(true) { while(true) {
if(StatusMonitor<T>::oneUp.watch < error) { if(StatusMonitor<T>::oneUp.watch <= error) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(StatusMonitor<T>::oneUp.watch < warning) { else if(StatusMonitor<T>::oneUp.watch <= warning) {
StatusMonitor<T>::status = WARNING; StatusMonitor<T>::status = WARNING;
} }
else { else {
......
...@@ -140,17 +140,17 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) { ...@@ -140,17 +140,17 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
//app.dumpConnections(); //app.dumpConnections();
auto warning = test.getScalar<uint>(std::string("/Monitor/lowerWarningThreshold")); auto warning = test.getScalar<uint>(std::string("/Monitor/lowerWarningThreshold"));
warning = 50; warning = 40;
warning.write(); warning.write();
test.stepApplication(); test.stepApplication();
auto error = test.getScalar<uint>(std::string("/Monitor/lowerErrorThreshold")); auto error = test.getScalar<uint>(std::string("/Monitor/lowerErrorThreshold"));
error = 45; error = 30;
error.write(); error.write();
test.stepApplication(); test.stepApplication();
auto watch = test.getScalar<uint>(std::string("/watch")); auto watch = test.getScalar<uint>(std::string("/watch"));
watch = 55; watch = 45;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
...@@ -160,61 +160,40 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) { ...@@ -160,61 +160,40 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
//should be in OK state. //should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK); BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//set watch value lower than warning threshold // just abow the lower warning limit
watch = 48; watch = 41;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in WARNING state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//set watch value greater than error threshold //exactly at the lower warning limit
watch = 42; watch = 40;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in ERROR state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//decrease error value lower than watch
error = 35;
error.write();
test.stepApplication();
status.readLatest();
//should be in WARNING state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING); BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//decrease warning value lower than watch //just above the lower error limit
warning = 40; watch = 31;
warning.write();
test.stepApplication();
status.readLatest();
//should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//set watch value lower than error threshold
watch = 33;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in ERROR state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//decrease watch value greater than error level but still lower than warning level //exactly at the lower error limit (only well defined for int)
watch = 36; watch = 30;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in WARNING state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//decrease watch value lower than warning level //way bellow the lower error limit
watch = 41; watch = 12;
watch.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
//should be in OK state. BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// check that the tags are applied correctly // check that the tags are applied correctly
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status"));
...@@ -329,35 +308,12 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) { ...@@ -329,35 +308,12 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) {
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR); BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//way bellow the lower error limit //way bellow the lower error limit
errorUpperLimit = 12; watch = 12;
errorUpperLimit.write(); watch.write();
test.stepApplication(); test.stepApplication();
status.readLatest(); status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR); BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// errorLowerLimit = 61;
// errorLowerLimit.write();
// test.stepApplication();
// warningUpperLimit = 60;
// warningUpperLimit.write();
// test.stepApplication();
// warningLowerLimit = 51;
// warningLowerLimit.write();
// test.stepApplication();
// status.readLatest();
// //should be in WARNING state.
// BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// warningLowerLimit = 55;
// warningLowerLimit.write();
// test.stepApplication();
// status.readLatest();
// //should be in OK state.
// BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// check that the tags are applied correctly // check that the tags are applied correctly
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MyNiceMonitorCopy/Monitor/status"));
BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status")); BOOST_CHECK_EQUAL(status, test.readScalar<uint16_t>("/MonitorOutput/Monitor/status"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment