all heaters off wrapper
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2023-04-06 13:01:31 +02:00
parent 19006e79b1
commit 3a236a1a3b
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 18 additions and 5 deletions

View File

@ -1031,7 +1031,7 @@ void ThermalController::ctrlAcsBoard() {
if (chooseHeater(switchNr, redSwitchNr)) { if (chooseHeater(switchNr, redSwitchNr)) {
if (heaterHandler.getSwitchState(switchNr)) { if (heaterHandler.getSwitchState(switchNr)) {
if (submode != SUBMODE_NO_HEATER_CTRL) { if (submode != SUBMODE_NO_HEATER_CTRL) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); heaterSwitchHelper(switchNr, HeaterHandler::SwitchState::OFF, thermalComponent);
} }
} }
} }
@ -1566,6 +1566,7 @@ void ThermalController::performThermalModuleCtrl(const HeaterSwitchStates& heate
void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) { void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) {
if (selectAndReadSensorTemp(htrCtx)) { if (selectAndReadSensorTemp(htrCtx)) {
if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) { if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) {
// Core loop for a thermal component, after sensors and heaters were selected.
checkLimitsAndCtrlHeater(htrCtx); checkLimitsAndCtrlHeater(htrCtx);
} }
} else { } else {
@ -1574,7 +1575,7 @@ void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) {
if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) { if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) {
if (heaterCtrlAllowed() and if (heaterCtrlAllowed() and
(heaterHandler.getSwitchState(htrCtx.switchNr) == HeaterHandler::SwitchState::ON)) { (heaterHandler.getSwitchState(htrCtx.switchNr) == HeaterHandler::SwitchState::ON)) {
heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::OFF); heaterSwitchHelper(htrCtx.switchNr, HeaterHandler::SwitchState::OFF, thermalComponent);
} }
} }
} }
@ -1786,6 +1787,19 @@ void ThermalController::heaterSwitchHelper(heater::Switch switchNr,
} }
} }
void ThermalController::heaterSwitchHelperAllOff() {
timeval currentTime;
Clock::getClockMonotonic(&currentTime);
size_t idx = 0;
for (; idx < heater::Switch::NUMBER_OF_SWITCHES; idx++) {
heaterHandler.switchHeater(static_cast<heater::Switch>(idx), HeaterHandler::SwitchState::OFF);
}
for (idx = 0; idx < thermalStates.size(); idx++) {
thermalStates[idx].heating = false;
thermalStates[idx].heaterEndTime = currentTime.tv_sec;
}
}
void ThermalController::tooHotHandlerWhichClearsOneShotFlag(object_id_t object, bool& oneShotFlag) { void ThermalController::tooHotHandlerWhichClearsOneShotFlag(object_id_t object, bool& oneShotFlag) {
// Clear the one shot flag is the component is in acceptable temperature range. // Clear the one shot flag is the component is in acceptable temperature range.
if (not tooHotHandler(object, oneShotFlag) and not componentAboveUpperLimit) { if (not tooHotHandler(object, oneShotFlag) and not componentAboveUpperLimit) {
@ -1798,9 +1812,7 @@ void ThermalController::startTransition(Mode_t mode_, Submode_t submode_) {
// For MODE_OFF and the no heater control submode, we command all switches to off before // For MODE_OFF and the no heater control submode, we command all switches to off before
// completing the transition. This ensures a consistent state when commanding these modes. // completing the transition. This ensures a consistent state when commanding these modes.
if ((mode_ == MODE_OFF) or ((mode_ == MODE_ON) and (submode_ == SUBMODE_NO_HEATER_CTRL))) { if ((mode_ == MODE_OFF) or ((mode_ == MODE_ON) and (submode_ == SUBMODE_NO_HEATER_CTRL))) {
for (uint8_t i = 0; i < heater::Switch::NUMBER_OF_SWITCHES; i++) { heaterSwitchHelperAllOff();
heaterHandler.switchHeater(static_cast<heater::Switch>(i), HeaterHandler::SwitchState::OFF);
}
transitionWhenHeatersOff = true; transitionWhenHeatersOff = true;
targetMode = mode_; targetMode = mode_;
targetSubmode = submode_; targetSubmode = submode_;

View File

@ -315,6 +315,7 @@ class ThermalController : public ExtendedControllerBase {
bool chooseHeater(heater::Switch& switchNr, heater::Switch redSwitchNr); bool chooseHeater(heater::Switch& switchNr, heater::Switch redSwitchNr);
bool selectAndReadSensorTemp(HeaterContext& htrCtx); bool selectAndReadSensorTemp(HeaterContext& htrCtx);
void heaterSwitchHelperAllOff();
void heaterSwitchHelper(heater::Switch switchNr, HeaterHandler::SwitchState state, void heaterSwitchHelper(heater::Switch switchNr, HeaterHandler::SwitchState state,
unsigned componentIdx); unsigned componentIdx);