Merge branch 'tcs-heater-upper-limit' into tcs-observability
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-07-07 16:21:42 +02:00
commit 2210ec3737
Signed by: muellerr
GPG Key ID: A649FB78196E3849
3 changed files with 17 additions and 8 deletions

View File

@ -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.

View File

@ -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<heater::Switch>(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<heater::Switch>(i), heater::SwitchState::OFF);
triggerEvent(tcsCtrl::TCS_HEATER_MAX_BURN_TIME_REACHED, static_cast<uint32_t>(i),
MAX_HEATER_ON_DURATIONS_MS[i]);
@ -1815,7 +1821,7 @@ void ThermalController::heaterMaxDurationControl(
// those components
crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast<heater::Switch>(i));
} else if (currentHeaterStates[i] == heater::SwitchState::OFF) {
heaterStates[i].heaterOnPeriod.resetTimer();
heaterStates[i].heaterOnMaxBurnTime.resetTimer();
}
}
}

View File

@ -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<heater::SwitchState, heater::NUMBER_OF_SWITCHES>;