From 950e86ce4bc4fa540c82061c1c81a7cd94cc8654 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 18 Mar 2024 10:56:57 +0100 Subject: [PATCH] cleaner solution --- mission/controller/ThermalController.cpp | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 31c5f663..ef21f2d9 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1643,21 +1643,22 @@ bool ThermalController::chooseHeater(heater::Switch& switchNr, heater::Switch re HasHealthIF::HealthState mainHealth = heaterHandler.getHealth(switchNr); heater::SwitchState mainState = heaterHandler.getSwitchState(switchNr); HasHealthIF::HealthState redHealth = heaterHandler.getHealth(redSwitchNr); - if (not(mainHealth == HasHealthIF::EXTERNAL_CONTROL and mainState == heater::SwitchState::ON)) { - if (mainHealth != HasHealthIF::HEALTHY) { - if (redHealth == HasHealthIF::HEALTHY) { - switchNr = redSwitchNr; - ctrlCtx.redSwitchNrInUse = true; - } else { - heaterAvailable = false; - // Special case: Ground might command/do something with the heaters, so prevent spam. - if (not(mainHealth == EXTERNAL_CONTROL and redHealth == EXTERNAL_CONTROL)) { - triggerEvent(tcsCtrl::NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); - } - } + if (mainHealth == HasHealthIF::EXTERNAL_CONTROL and mainState == heater::SwitchState::ON) { + return false; + } + if (mainHealth != HasHealthIF::HEALTHY) { + if (redHealth == HasHealthIF::HEALTHY) { + switchNr = redSwitchNr; + ctrlCtx.redSwitchNrInUse = true; } else { - ctrlCtx.redSwitchNrInUse = false; + heaterAvailable = false; + // Special case: Ground might command/do something with the heaters, so prevent spam. + if (not(mainHealth == EXTERNAL_CONTROL and redHealth == EXTERNAL_CONTROL)) { + triggerEvent(tcsCtrl::NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + } } + } else { + ctrlCtx.redSwitchNrInUse = false; } return heaterAvailable; @@ -1714,7 +1715,8 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { if (thermalStates[ctrlCtx.thermalComponent].heating) { // We are already in a heating cycle, so need to check whether heating task is complete. if (ctrlCtx.sensorTemp >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET and - heaterCtrlAllowed()) { + heaterCtrlAllowed() /*and + heaterHandler.getHealth(htrCtx.switchNr) != HasHealthIF::EXTERNAL_CONTROL*/) { sif::info << "TCS: Heater " << static_cast(ctrlCtx.thermalComponent) << " OFF" << std::endl; heaterSwitchHelper(htrCtx.switchNr, heater::SwitchState::OFF, ctrlCtx.thermalComponent);