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

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
1 changed files with 35 additions and 23 deletions

View File

@ -1539,8 +1539,33 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
const TempLimits& tempLimit) {
componentAboveCutOffLimit = 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) {
// Heater off
if (not heaterHandler.checkSwitchState(switchNr)) {
// TODO: check NOP limit and maybe trigger fdir
if (sensorTemp < tempLimit.opLowerLimit) {
@ -1552,10 +1577,11 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
} else {
thermalStates[thermalComponent].heating = false;
}
// if Heater on
checkUpperLimits(false);
// Heater on
} else if (heaterHandler.checkSwitchState(switchNr)) {
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) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater "
@ -1564,28 +1590,14 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
thermalStates[thermalComponent].heating = false;
}
} else {
auto tempTooHighHandler = [&](const char* whatLimit) {
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 (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;
}
// This can happen if heater is used as alternative heater (no regular heating cycle), so we
// should still check the upper limits.
bool tooHighHandlerAlreadyCalled = checkUpperLimits(true);
if (sensorTemp >= tempLimit.cutOffLimit) {
componentAboveCutOffLimit = true;
tempTooHighHandler("CutOff-Limit");
if (not tooHighHandlerAlreadyCalled) {
tempTooHighHandler("CutOff-Limit", true);
}
}
}
}