this should be better
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
2023-07-10 13:28:36 +02:00
parent 106d73238b
commit 33de08eafc
4 changed files with 26 additions and 11 deletions

View File

@ -1791,9 +1791,10 @@ void ThermalController::heaterMaxDurationControl(const HeaterSwitchStates& curre
heaterStates[i].switchTransition = false;
heaterStates[i].heaterSwitchControlCycles = 0;
heaterStates[i].trackHeaterMaxPeriod = false;
heaterHandler.switchHeater(static_cast<heater::Switch>(i), HeaterHandler::SwitchState::OFF);
triggerEvent(tcsCtrl::TCS_HEATER_MAX_BURN_TIME_REACHED, static_cast<uint32_t>(i),
MAX_HEATER_ON_DURATIONS_MS[i]);
heaterSwitchHelper(static_cast<heater::Switch>(i), HeaterHandler::SwitchState::OFF,
std::nullopt);
// The heater might still be one for some thermal components, so cross-check
// those components
crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast<heater::Switch>(i));
@ -1847,23 +1848,28 @@ void ThermalController::resetThermalStates() {
void ThermalController::heaterSwitchHelper(heater::Switch switchNr,
HeaterHandler::SwitchState targetState,
unsigned componentIdx) {
std::optional<unsigned> componentIdx) {
timeval currentTime;
Clock::getClockMonotonic(&currentTime);
if (targetState == HeaterHandler::SwitchState::ON) {
heaterHandler.switchHeater(switchNr, targetState);
heaterStates[switchNr].target = HeaterHandler::SwitchState::ON;
heaterStates[switchNr].switchTransition = true;
thermalStates[componentIdx].sensorIndex = currentSensorIndex;
thermalStates[componentIdx].heaterSwitch = switchNr;
thermalStates[componentIdx].heating = true;
thermalStates[componentIdx].heaterStartTime = currentTime.tv_sec;
if (componentIdx.has_value()) {
unsigned componentIdxVal = componentIdx.value();
thermalStates[componentIdxVal].sensorIndex = currentSensorIndex;
thermalStates[componentIdxVal].heaterSwitch = switchNr;
thermalStates[componentIdxVal].heating = true;
thermalStates[componentIdxVal].heaterStartTime = currentTime.tv_sec;
}
triggerEvent(tcsCtrl::TCS_SWITCHING_HEATER_ON, static_cast<uint32_t>(currThermalComponent),
static_cast<uint32_t>(switchNr));
} else {
heaterHandler.switchHeater(switchNr, targetState);
thermalStates[componentIdx].heating = false;
thermalStates[componentIdx].heaterEndTime = currentTime.tv_sec;
if (componentIdx.has_value()) {
thermalStates[componentIdx.value()].heating = false;
thermalStates[componentIdx.value()].heaterEndTime = currentTime.tv_sec;
}
triggerEvent(tcsCtrl::TCS_SWITCHING_HEATER_OFF, static_cast<uint32_t>(currThermalComponent),
static_cast<uint32_t>(switchNr));
}