diff --git a/CHANGELOG.md b/CHANGELOG.md index e70d4d49..63a71f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ will consitute of a breaking change warranting a new major release: - Two events for heaters being commanded ON and OFF by the TCS controller - Upper limit for burn time of TCS heaters. Currently set to 1 hour for each heater. + This mechanism will only track the burn time for heaters which were commanded by the + TCS controller. - TCS controller is now observable by introducing a new HK dataset which exposes some internal fields related to TCS control. diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f932c762..fe30959f 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1781,9 +1781,11 @@ void ThermalController::heaterTransitionControl( if (currentHeaterStates[i] == heaterStates[i].target) { // Required for max heater period control if (currentHeaterStates[i] == heater::SwitchState::ON) { - heaterStates[i].heaterOnPeriod.setTimeout(MAX_HEATER_ON_DURATIONS_MS[i]); - heaterStates[i].heaterOnPeriod.resetTimer(); + heaterStates[i].heaterOnMaxBurnTime.setTimeout(MAX_HEATER_ON_DURATIONS_MS[i]); + heaterStates[i].heaterOnMaxBurnTime.resetTimer(); + heaterStates[i].trackHeaterMaxBurnTime = true; } else { + heaterStates[i].trackHeaterMaxBurnTime = false; // The heater might still be one for some thermal components, so cross-check // those components crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast(i)); @@ -1804,10 +1806,14 @@ void ThermalController::heaterTransitionControl( void ThermalController::heaterMaxDurationControl( const tcsCtrl::HeaterSwitchStates& currentHeaterStates) { for (unsigned i = 0; i < heater::Switch::NUMBER_OF_SWITCHES; i++) { + // Right now, we only track the maximum duration for heater which were commanded by the TCS + // controller. if (currentHeaterStates[i] == heater::SwitchState::ON and - heaterStates[i].heaterOnPeriod.hasTimedOut()) { + heaterStates[i].trackHeaterMaxBurnTime and + heaterStates[i].heaterOnMaxBurnTime.hasTimedOut()) { heaterStates[i].switchTransition = false; heaterStates[i].heaterSwitchControlCycles = 0; + heaterStates[i].trackHeaterMaxBurnTime = false; heaterHandler.switchHeater(static_cast(i), heater::SwitchState::OFF); triggerEvent(tcsCtrl::TCS_HEATER_MAX_BURN_TIME_REACHED, static_cast(i), MAX_HEATER_ON_DURATIONS_MS[i]); @@ -1815,7 +1821,7 @@ void ThermalController::heaterMaxDurationControl( // those components crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast(i)); } else if (currentHeaterStates[i] == heater::SwitchState::OFF) { - heaterStates[i].heaterOnPeriod.resetTimer(); + heaterStates[i].heaterOnMaxBurnTime.resetTimer(); } } } diff --git a/mission/controller/tcsDefs.h b/mission/controller/tcsDefs.h index 1b2b968b..48f5f605 100644 --- a/mission/controller/tcsDefs.h +++ b/mission/controller/tcsDefs.h @@ -51,10 +51,11 @@ struct ThermalState { * Abstraction for the state of a single heater. */ struct HeaterState { - bool switchTransition; - heater::SwitchState target; - uint8_t heaterSwitchControlCycles; - Countdown heaterOnPeriod; + bool switchTransition = false; + heater::SwitchState target = heater::SwitchState::OFF; + uint8_t heaterSwitchControlCycles = 0; + bool trackHeaterMaxBurnTime = false; + Countdown heaterOnMaxBurnTime; }; using HeaterSwitchStates = std::array;