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

StatusMonitor

- worked around gcc bug buy adding a useless default constructor
- removed dangerous convenience referene which would be broken by copy constructor and assignment operator
parent daeb246c
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,8 @@ namespace ChimeraTK { ...@@ -45,6 +45,8 @@ namespace ChimeraTK {
: ApplicationModule(owner, name, description, modifier, tags), _parameterTags(parameterTags), oneUp(this, input), : ApplicationModule(owner, name, description, modifier, tags), _parameterTags(parameterTags), oneUp(this, input),
status(this, output, "", "", outputTags) {} status(this, output, "", "", outputTags) {}
StatusMonitor() { throw logic_error("Default constructor unusable. Just exists to work around gcc bug."); }
~StatusMonitor() override {} ~StatusMonitor() override {}
void prepare() override {} void prepare() override {}
...@@ -57,9 +59,6 @@ namespace ChimeraTK { ...@@ -57,9 +59,6 @@ namespace ChimeraTK {
ScalarPushInput<T> watch; ScalarPushInput<T> watch;
} oneUp; } oneUp;
// Conveniance reference to avoid the "oneUp" in the code
ScalarPushInput<T>& watch = oneUp.watch;
/**One of four possible states to be reported*/ /**One of four possible states to be reported*/
ScalarOutput<uint16_t> status; ScalarOutput<uint16_t> status;
}; };
...@@ -76,13 +75,13 @@ namespace ChimeraTK { ...@@ -76,13 +75,13 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
void mainLoop() { void mainLoop() {
/** 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>::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>::watch > error) { if(StatusMonitor<T>::oneUp.watch > error) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(StatusMonitor<T>::watch > warning) { else if(StatusMonitor<T>::oneUp.watch > warning) {
StatusMonitor<T>::status = WARNING; StatusMonitor<T>::status = WARNING;
} }
else { else {
...@@ -107,12 +106,12 @@ namespace ChimeraTK { ...@@ -107,12 +106,12 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
void mainLoop() { void mainLoop() {
/** 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>::watch, warning, error}; ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warning, error};
while(true) { while(true) {
if(StatusMonitor<T>::watch < error) { if(StatusMonitor<T>::oneUp.watch < error) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(StatusMonitor<T>::watch < warning) { else if(StatusMonitor<T>::oneUp.watch < warning) {
StatusMonitor<T>::status = WARNING; StatusMonitor<T>::status = WARNING;
} }
else { else {
...@@ -149,8 +148,8 @@ namespace ChimeraTK { ...@@ -149,8 +148,8 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
void mainLoop() { void mainLoop() {
/** 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>::watch, warningUpperThreshold, warningLowerThreshold, errorUpperThreshold, ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, warningUpperThreshold, warningLowerThreshold,
errorLowerThreshold}; errorUpperThreshold, errorLowerThreshold};
while(true) { while(true) {
T warningUpperThresholdCorrected = warningUpperThreshold; T warningUpperThresholdCorrected = warningUpperThreshold;
T errorUpperThresholdCorrected = errorUpperThreshold; T errorUpperThresholdCorrected = errorUpperThreshold;
...@@ -162,11 +161,12 @@ namespace ChimeraTK { ...@@ -162,11 +161,12 @@ namespace ChimeraTK {
if(errorUpperThresholdCorrected < errorLowerThreshold) { if(errorUpperThresholdCorrected < errorLowerThreshold) {
errorUpperThresholdCorrected = errorLowerThreshold; errorUpperThresholdCorrected = errorLowerThreshold;
} }
if(StatusMonitor<T>::watch <= errorUpperThresholdCorrected && StatusMonitor<T>::watch >= errorLowerThreshold) { if(StatusMonitor<T>::oneUp.watch <= errorUpperThresholdCorrected &&
StatusMonitor<T>::oneUp.watch >= errorLowerThreshold) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(StatusMonitor<T>::watch <= warningUpperThresholdCorrected && else if(StatusMonitor<T>::oneUp.watch <= warningUpperThresholdCorrected &&
StatusMonitor<T>::watch >= warningLowerThreshold) { StatusMonitor<T>::oneUp.watch >= warningLowerThreshold) {
StatusMonitor<T>::status = WARNING; StatusMonitor<T>::status = WARNING;
} }
else { else {
...@@ -190,9 +190,9 @@ namespace ChimeraTK { ...@@ -190,9 +190,9 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
void mainLoop() { void mainLoop() {
/** If there is a change either in value monitored or in requiredValue, the status is re-evaluated*/ /** If there is a change either in value monitored or in requiredValue, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::watch, requiredValue}; ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, requiredValue};
while(true) { while(true) {
if(StatusMonitor<T>::watch != requiredValue) { if(StatusMonitor<T>::oneUp.watch != requiredValue) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else { else {
...@@ -218,9 +218,9 @@ namespace ChimeraTK { ...@@ -218,9 +218,9 @@ namespace ChimeraTK {
/**This is where state evaluation is done*/ /**This is where state evaluation is done*/
void mainLoop() { void mainLoop() {
/** If there is a change either in value monitored or in state, the status is re-evaluated*/ /** If there is a change either in value monitored or in state, the status is re-evaluated*/
ReadAnyGroup group{StatusMonitor<T>::watch, nominalState}; ReadAnyGroup group{StatusMonitor<T>::oneUp.watch, nominalState};
while(true) { while(true) {
if(StatusMonitor<T>::watch != nominalState) { if(StatusMonitor<T>::oneUp.watch != nominalState) {
StatusMonitor<T>::status = ERROR; StatusMonitor<T>::status = ERROR;
} }
else if(nominalState == OK || nominalState == OFF) { else if(nominalState == OK || nominalState == OFF) {
......
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