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

StatusMonitors can be disabled.

parent f3d2c1fe
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,11 @@ namespace ChimeraTK {
/**One of four possible states to be reported*/
ScalarOutput<uint16_t> status;
/** Disable the monitor. The status will always be OFF. You don't have to connect this input.
* When there is no feeder, ApplicationCore will connect it to a constant feeder with value 0, hence the monitor is always enabled.
*/
ScalarPushInput<int> disable{this, "disable", "", "Disable the status monitor"};
};
/** Module for status monitoring depending on a maximum threshold value*/
......@@ -78,10 +83,13 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/
void mainLoop() {
/** 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, StatusMonitor<T>::disable, warning, error};
while(true) {
// 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>::disable != 0) {
StatusMonitor<T>::status = OFF;
}
else if(StatusMonitor<T>::oneUp.watch >= error) {
StatusMonitor<T>::status = ERROR;
}
else if(StatusMonitor<T>::oneUp.watch >= warning) {
......@@ -109,9 +117,12 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/
void mainLoop() {
/** 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, StatusMonitor<T>::disable, warning, error};
while(true) {
if(StatusMonitor<T>::oneUp.watch <= error) {
if(StatusMonitor<T>::disable != 0) {
StatusMonitor<T>::status = OFF;
}
else if(StatusMonitor<T>::oneUp.watch <= error) {
StatusMonitor<T>::status = ERROR;
}
else if(StatusMonitor<T>::oneUp.watch <= warning) {
......@@ -151,12 +162,15 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/
void mainLoop() {
/** If there is a change either in value monitored or in thershold values, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warningUpperThreshold, warningLowerThreshold,
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, StatusMonitor<T>::disable, warningUpperThreshold, warningLowerThreshold,
errorUpperThreshold, errorLowerThreshold};
while(true) {
if(StatusMonitor<T>::disable != 0) {
StatusMonitor<T>::status = OFF;
}
// Check for error limits first. Like this they supersede the warning,
// even if they are stricter then the warning limits (mis-configuration)
if(StatusMonitor<T>::oneUp.watch <= errorLowerThreshold ||
else if(StatusMonitor<T>::oneUp.watch <= errorLowerThreshold ||
StatusMonitor<T>::oneUp.watch >= errorUpperThreshold) {
StatusMonitor<T>::status = ERROR;
}
......@@ -185,9 +199,12 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/
void mainLoop() {
/** If there is a change either in value monitored or in requiredValue, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, requiredValue};
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, StatusMonitor<T>::disable, requiredValue};
while(true) {
if(StatusMonitor<T>::oneUp.watch != requiredValue) {
if(StatusMonitor<T>::disable != 0) {
StatusMonitor<T>::status = OFF;
}
else if(StatusMonitor<T>::oneUp.watch != requiredValue) {
StatusMonitor<T>::status = ERROR;
}
else {
......@@ -213,9 +230,12 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/
void mainLoop() {
/** If there is a change either in value monitored or in state, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, nominalState};
ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, StatusMonitor<T>::disable, nominalState};
while(true) {
if(StatusMonitor<T>::oneUp.watch != nominalState) {
if(StatusMonitor<T>::disable != 0) {
StatusMonitor<T>::status = OFF;
}
else if(StatusMonitor<T>::oneUp.watch != nominalState) {
StatusMonitor<T>::status = ERROR;
}
else if(nominalState == OK || nominalState == OFF) {
......
......@@ -72,6 +72,20 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// drop in a disable test.
auto disable = test.getScalar<int>("/Monitor/disable");
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// slightly above at the upper warning threshold (exact is not good due to rounding errors in floats/doubles)
watch = 50.01;
watch.write();
......@@ -79,6 +93,19 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//just below the error threshold,. still warning
watch = 59.99;
watch.write();
......@@ -93,6 +120,19 @@ BOOST_AUTO_TEST_CASE(testMaxMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//increase well above the upper error level
watch = 65;
watch.write();
......@@ -172,6 +212,20 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// drop in a disable test.
auto disable = test.getScalar<int>("/Monitor/disable");
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//exactly at the lower warning limit
watch = 40;
watch.write();
......@@ -179,6 +233,19 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//just above the lower error limit
watch = 31;
watch.write();
......@@ -193,6 +260,19 @@ BOOST_AUTO_TEST_CASE(testMinMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//way bellow the lower error limit
watch = 12;
watch.write();
......@@ -285,6 +365,20 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// drop in a disable test.
auto disable = test.getScalar<int>("/Monitor/disable");
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//exactly at the upper warning threshold (only well defined for int)
watch = 50;
watch.write();
......@@ -292,6 +386,19 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::WARNING);
//just below the error threshold,. still warning
watch = 59;
watch.write();
......@@ -306,6 +413,19 @@ BOOST_AUTO_TEST_CASE(testRangeMonitor) {
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
//increase well above the upper error level
watch = 65;
watch.write();
......@@ -442,6 +562,20 @@ BOOST_AUTO_TEST_CASE(testExactMonitor) {
//should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// drop in a disable test.
auto disable = test.getScalar<int>("/Monitor/disable");
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
//set watch value different than required value
watch = 41.4;
watch.write();
......@@ -450,6 +584,19 @@ BOOST_AUTO_TEST_CASE(testExactMonitor) {
//should be in ERROR state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
watch = 40.9;
watch.write();
test.stepApplication();
......@@ -505,6 +652,20 @@ BOOST_AUTO_TEST_CASE(testStateMonitor) {
//should be in OK state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
// drop in a disable test.
auto disable = test.getScalar<int>("/Monitor/disable");
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OK);
watch = 0;
watch.write();
test.stepApplication();
......@@ -512,6 +673,19 @@ BOOST_AUTO_TEST_CASE(testStateMonitor) {
//should be in ERROR state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// drop in a disable test.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
stateValue = 0;
stateValue.write();
test.stepApplication();
......@@ -519,6 +693,29 @@ BOOST_AUTO_TEST_CASE(testStateMonitor) {
//should be in OFF state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
// State change while disabled is detected.
disable=1;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
// it is still disabled
stateValue = 1; // should be OK, but watch is still 0 => result would be ERROR if it was not disabled
stateValue.write();
test.stepApplication();
status.readLatest();
//should be in OFF state.
BOOST_CHECK_EQUAL(status, ChimeraTK::States::OFF);
// after enabling the ERROR becomes visible
disable=0;
disable.write();
test.stepApplication();
status.readLatest();
BOOST_CHECK_EQUAL(status, ChimeraTK::States::ERROR);
// 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>("/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