this should cover upper bound checking when heater is off
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-03-15 15:43:20 +01:00
parent dc44af5b29
commit 715a69db89
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -1539,8 +1539,33 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
const TempLimits& tempLimit) { const TempLimits& tempLimit) {
componentAboveCutOffLimit = false; componentAboveCutOffLimit = false;
componentAboveUpperLimit = false; componentAboveUpperLimit = false;
// if Heater off auto tempTooHighHandler = [&](const char* whatLimit, bool heaterIsOn) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Reached " << whatLimit << ": Heater "
<< static_cast<int>(thermalComponent) << " OFF" << std::endl;
heaterStates[switchNr].switchTransition = true;
if (heaterIsOn) {
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
heaterStates[redSwitchNr].switchTransition = true;
}
};
auto checkUpperLimits = [&](bool heaterIsOn) {
if (sensorTemp >= tempLimit.nopUpperLimit) {
componentAboveUpperLimit = true;
tempTooHighHandler("NOP-Limit", heaterIsOn);
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH;
return true;
} else if (sensorTemp >= tempLimit.opUpperLimit) {
componentAboveUpperLimit = true;
tempTooHighHandler("OP-Limit", heaterIsOn);
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_HIGH;
return true;
}
return false;
};
// Stay passive during switch transitions, wait for heater switching to complete.
if (not heaterStates[switchNr].switchTransition) { if (not heaterStates[switchNr].switchTransition) {
// Heater off
if (not heaterHandler.checkSwitchState(switchNr)) { if (not heaterHandler.checkSwitchState(switchNr)) {
// TODO: check NOP limit and maybe trigger fdir // TODO: check NOP limit and maybe trigger fdir
if (sensorTemp < tempLimit.opLowerLimit) { if (sensorTemp < tempLimit.opLowerLimit) {
@ -1552,10 +1577,11 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
} else { } else {
thermalStates[thermalComponent].heating = false; thermalStates[thermalComponent].heating = false;
} }
checkUpperLimits(false);
// if Heater on // Heater on
} else if (heaterHandler.checkSwitchState(switchNr)) { } else if (heaterHandler.checkSwitchState(switchNr)) {
if (thermalStates[thermalComponent].heating) { if (thermalStates[thermalComponent].heating) {
// We are already in a heating cycle, so need to check whether heating task is complete.
if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater "
@ -1564,28 +1590,14 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
thermalStates[thermalComponent].heating = false; thermalStates[thermalComponent].heating = false;
} }
} else { } else {
auto tempTooHighHandler = [&](const char* whatLimit) { // This can happen if heater is used as alternative heater (no regular heating cycle), so we
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); // should still check the upper limits.
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Reached " << whatLimit bool tooHighHandlerAlreadyCalled = checkUpperLimits(true);
<< ": Heater " << static_cast<int>(thermalComponent) << " OFF" << std::endl;
heaterStates[switchNr].switchTransition = true;
if (heaterHandler.checkSwitchState(redSwitchNr)) {
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
heaterStates[redSwitchNr].switchTransition = true;
}
};
if (sensorTemp >= tempLimit.nopUpperLimit) {
componentAboveUpperLimit = true;
tempTooHighHandler("NOP-Limit");
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH;
} else if (sensorTemp >= tempLimit.opUpperLimit) {
componentAboveUpperLimit = true;
tempTooHighHandler("OP-Limit");
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_HIGH;
}
if (sensorTemp >= tempLimit.cutOffLimit) { if (sensorTemp >= tempLimit.cutOffLimit) {
componentAboveCutOffLimit = true; componentAboveCutOffLimit = true;
tempTooHighHandler("CutOff-Limit"); if (not tooHighHandlerAlreadyCalled) {
tempTooHighHandler("CutOff-Limit", true);
}
} }
} }
} }