fsfw/thermal/ThermalMonitorReporter.cpp

71 lines
2.3 KiB
C++
Raw Normal View History

2020-11-19 00:10:59 +01:00
#include "ThermalMonitorReporter.h"
#include "ThermalComponentIF.h"
2020-08-28 18:33:29 +02:00
#include "../monitoring/MonitoringIF.h"
2020-11-19 00:10:59 +01:00
ThermalMonitorReporter::~ThermalMonitorReporter() {
2020-08-28 18:33:29 +02:00
}
2020-11-19 00:10:59 +01:00
void ThermalMonitorReporter::sendTransitionEvent(float currentValue,
2020-08-28 18:33:29 +02:00
ReturnValue_t state) {
switch (state) {
case MonitoringIF::BELOW_LOW_LIMIT:
EventManagerIF::triggerEvent(reportingId,
ThermalComponentIF::COMPONENT_TEMP_OOL_LOW, state);
break;
case MonitoringIF::ABOVE_HIGH_LIMIT:
EventManagerIF::triggerEvent(reportingId,
ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH, state);
break;
case ThermalComponentIF::BELOW_OPERATIONAL_LIMIT:
EventManagerIF::triggerEvent(reportingId,
ThermalComponentIF::COMPONENT_TEMP_LOW, state);
break;
case ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT:
EventManagerIF::triggerEvent(reportingId,
ThermalComponentIF::COMPONENT_TEMP_HIGH, state);
break;
default:
break;
}
}
2020-11-19 00:10:59 +01:00
bool ThermalMonitorReporter::isAboveHighLimit() {
2020-08-28 18:33:29 +02:00
if (oldState == ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT) {
return true;
} else {
return false;
}
}
2020-11-19 00:10:59 +01:00
ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State state, float sample, float lowerLimit,
2020-08-28 18:33:29 +02:00
float upperLimit, bool componentIsOperational) {
if (ThermalComponentIF::isIgnoredState(state)) {
setToUnchecked();
return MonitoringIF::UNCHECKED;
}
switch (state) {
case ThermalComponentIF::OUT_OF_RANGE_LOW:
return monitorStateIs(MonitoringIF::BELOW_LOW_LIMIT, sample, lowerLimit);
case ThermalComponentIF::NON_OPERATIONAL_LOW:
if (componentIsOperational) {
return monitorStateIs(ThermalComponentIF::BELOW_OPERATIONAL_LIMIT, sample, lowerLimit);
} else {
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
}
case ThermalComponentIF::OPERATIONAL:
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
case ThermalComponentIF::NON_OPERATIONAL_HIGH:
if (componentIsOperational) {
return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT, sample, upperLimit);
} else {
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
}
case ThermalComponentIF::OUT_OF_RANGE_HIGH:
return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample, upperLimit);
default:
//Never reached, all states covered.
return HasReturnvaluesIF::RETURN_FAILED;
}
}