From 096328aadca7d839b7721739bffba6878715ec74 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 18 Mar 2024 10:34:21 +0100 Subject: [PATCH] backup heater will not be chosen if heater is on ext ctrl and on --- mission/controller/ThermalController.cpp | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 7d8d99a0..31c5f663 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1641,21 +1641,25 @@ bool ThermalController::chooseHeater(heater::Switch& switchNr, heater::Switch re bool heaterAvailable = true; HasHealthIF::HealthState mainHealth = heaterHandler.getHealth(switchNr); + heater::SwitchState mainState = heaterHandler.getSwitchState(switchNr); HasHealthIF::HealthState redHealth = heaterHandler.getHealth(redSwitchNr); - 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 (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); + } } + } else { + ctrlCtx.redSwitchNrInUse = false; } - } else { - ctrlCtx.redSwitchNrInUse = false; } + return heaterAvailable; }