fsfw/src/fsfw/thermal/ThermalMonitorReporter.cpp

66 lines
2.5 KiB
C++
Raw Permalink Normal View History

2021-07-13 20:58:45 +02:00
#include "fsfw/thermal/ThermalMonitorReporter.h"
2020-12-03 18:32:32 +01:00
2021-07-13 20:58:45 +02:00
#include "fsfw/monitoring/MonitoringIF.h"
2022-02-02 10:29:30 +01:00
#include "fsfw/thermal/ThermalComponentIF.h"
2020-12-03 18:32:32 +01:00
2022-02-02 10:29:30 +01:00
ThermalMonitorReporter::~ThermalMonitorReporter() {}
2020-12-03 18:32:32 +01:00
2022-02-02 10:29:30 +01:00
void ThermalMonitorReporter::sendTransitionEvent(float currentValue, 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-12-03 18:32:32 +01:00
}
bool ThermalMonitorReporter::isAboveHighLimit() {
2022-02-02 10:29:30 +01:00
if (oldState == ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT) {
return true;
} else {
return false;
}
2020-12-03 18:32:32 +01:00
}
2022-02-02 10:29:30 +01:00
ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State state, float sample,
float lowerLimit, 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 {
2022-08-16 01:08:26 +02:00
return monitorStateIs(returnvalue::OK, sample, 0.0);
2022-02-02 10:29:30 +01:00
}
case ThermalComponentIF::OPERATIONAL:
2022-08-16 01:08:26 +02:00
return monitorStateIs(returnvalue::OK, sample, 0.0);
2022-02-02 10:29:30 +01:00
case ThermalComponentIF::NON_OPERATIONAL_HIGH:
if (componentIsOperational) {
return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT, sample, upperLimit);
} else {
2022-08-16 01:08:26 +02:00
return monitorStateIs(returnvalue::OK, sample, 0.0);
2022-02-02 10:29:30 +01:00
}
case ThermalComponentIF::OUT_OF_RANGE_HIGH:
return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample, upperLimit);
default:
// Never reached, all states covered.
2022-08-16 01:08:26 +02:00
return returnvalue::FAILED;
2022-02-02 10:29:30 +01:00
}
2020-12-03 18:32:32 +01:00
}