event spam has stopped
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-04-03 14:09:54 +02:00
parent 62952b89b1
commit e9c5bfe324
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
6 changed files with 162 additions and 119 deletions

View File

@ -209,11 +209,13 @@ const char *TRANSITION_OTHER_SIDE_FAILED_STRING = "TRANSITION_OTHER_SIDE_FAILED"
const char *NOT_ENOUGH_DEVICES_DUAL_MODE_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE";
const char *POWER_STATE_MACHINE_TIMEOUT_STRING = "POWER_STATE_MACHINE_TIMEOUT";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING = "SIDE_SWITCH_TRANSITION_NOT_ALLOWED";
const char *DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY_STRING = "DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY";
const char *DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY_STRING =
"DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY";
const char *TRANSITION_OTHER_SIDE_FAILED_12900_STRING = "TRANSITION_OTHER_SIDE_FAILED_12900";
const char *NOT_ENOUGH_DEVICES_DUAL_MODE_12901_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE_12901";
const char *POWER_STATE_MACHINE_TIMEOUT_12902_STRING = "POWER_STATE_MACHINE_TIMEOUT_12902";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903_STRING = "SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903_STRING =
"SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903";
const char *CHILDREN_LOST_MODE_STRING = "CHILDREN_LOST_MODE";
const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE";
const char *CANT_GET_FIX_STRING = "CANT_GET_FIX";

View File

@ -209,11 +209,13 @@ const char *TRANSITION_OTHER_SIDE_FAILED_STRING = "TRANSITION_OTHER_SIDE_FAILED"
const char *NOT_ENOUGH_DEVICES_DUAL_MODE_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE";
const char *POWER_STATE_MACHINE_TIMEOUT_STRING = "POWER_STATE_MACHINE_TIMEOUT";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING = "SIDE_SWITCH_TRANSITION_NOT_ALLOWED";
const char *DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY_STRING = "DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY";
const char *DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY_STRING =
"DIRECT_TRANSITION_TO_DUAL_OTHER_GPS_FAULTY";
const char *TRANSITION_OTHER_SIDE_FAILED_12900_STRING = "TRANSITION_OTHER_SIDE_FAILED_12900";
const char *NOT_ENOUGH_DEVICES_DUAL_MODE_12901_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE_12901";
const char *POWER_STATE_MACHINE_TIMEOUT_12902_STRING = "POWER_STATE_MACHINE_TIMEOUT_12902";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903_STRING = "SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903";
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903_STRING =
"SIDE_SWITCH_TRANSITION_NOT_ALLOWED_12903";
const char *CHILDREN_LOST_MODE_STRING = "CHILDREN_LOST_MODE";
const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE";
const char *CANT_GET_FIX_STRING = "CANT_GET_FIX";

View File

@ -984,7 +984,8 @@ void ThermalController::ctrlAcsBoard() {
numSensors = 5;
if (selectAndReadSensorTemp()) {
if (chooseHeater(switchNr, redSwitchNr)) {
checkLimitsAndCtrlHeater(switchNr, redSwitchNr, acsBoardLimits);
HeaterContext htrCtx(switchNr, redSwitchNr, acsBoardLimits);
checkLimitsAndCtrlHeater(htrCtx);
}
resetSensorsArray();
return;
@ -1002,11 +1003,12 @@ void ThermalController::ctrlAcsBoard() {
numSensors = 4;
if (selectAndReadSensorTemp()) {
if (chooseHeater(switchNr, redSwitchNr)) {
checkLimitsAndCtrlHeater(switchNr, redSwitchNr, acsBoardLimits);
HeaterContext htrCtx(switchNr, redSwitchNr, acsBoardLimits);
checkLimitsAndCtrlHeater(htrCtx);
}
} else {
if (chooseHeater(switchNr, redSwitchNr)) {
if (heaterHandler.checkSwitchState(switchNr)) {
if (heaterHandler.getSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
}
}
@ -1023,7 +1025,8 @@ void ThermalController::ctrlMgt() {
sensors[2].first = sensorTemperatures.plpcduHeatspreader.isValid();
sensors[2].second = sensorTemperatures.plpcduHeatspreader.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, mgtLimits);
HeaterContext htrCtx(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, mgtLimits);
ctrlComponentTemperature(htrCtx);
// TODO: trigger special event
}
@ -1044,12 +1047,15 @@ void ThermalController::ctrlRw() {
sensors[3].first = sensorTemperatures.dro.isValid();
sensors[3].second = sensorTemperatures.dro.value;
numSensors = 4;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
{
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
ctrlComponentTemperature(htrCtx);
sensorTemps[0] = tempFloatToU32();
if (componentAboveUpperLimit) {
oneIsAboveLimit = true;
eventToTrigger = overHeatEventToTrigger;
}
}
// RW2
thermalComponent = RW;
@ -1062,7 +1068,9 @@ void ThermalController::ctrlRw() {
sensors[3].first = sensorTemperatures.dro.isValid();
sensors[3].second = sensorTemperatures.dro.value;
numSensors = 4;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
{
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
ctrlComponentTemperature(htrCtx);
sensorTemps[1] = tempFloatToU32();
if (componentAboveUpperLimit) {
oneIsAboveLimit = true;
@ -1070,7 +1078,7 @@ void ThermalController::ctrlRw() {
eventToTrigger = overHeatEventToTrigger;
}
}
}
// RW3
thermalComponent = RW;
sensors[0].first = deviceTemperatures.rw3.isValid();
@ -1082,7 +1090,9 @@ void ThermalController::ctrlRw() {
sensors[3].first = sensorTemperatures.dro.isValid();
sensors[3].second = sensorTemperatures.dro.value;
numSensors = 4;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
{
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
ctrlComponentTemperature(htrCtx);
sensorTemps[2] = tempFloatToU32();
if (componentAboveUpperLimit) {
oneIsAboveLimit = true;
@ -1090,6 +1100,7 @@ void ThermalController::ctrlRw() {
eventToTrigger = overHeatEventToTrigger;
}
}
}
// RW4
thermalComponent = RW;
@ -1102,7 +1113,9 @@ void ThermalController::ctrlRw() {
sensors[3].first = sensorTemperatures.dro.isValid();
sensors[3].second = sensorTemperatures.dro.value;
numSensors = 4;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
{
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits);
ctrlComponentTemperature(htrCtx);
sensorTemps[3] = tempFloatToU32();
if (componentAboveUpperLimit) {
oneIsAboveLimit = true;
@ -1110,6 +1123,7 @@ void ThermalController::ctrlRw() {
eventToTrigger = overHeatEventToTrigger;
}
}
}
if (oneIsAboveLimit and not rwTooHotFlag) {
EventManagerIF::triggerEvent(objects::RW1, eventToTrigger, sensorTemps[0]);
@ -1131,7 +1145,8 @@ void ThermalController::ctrlStr() {
sensors[2].first = sensorTemperatures.dro.isValid();
sensors[2].second = sensorTemperatures.dro.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits);
HeaterContext htrCtx(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandlerWhichClearsOneShotFlag(objects::STAR_TRACKER, strTooHotFlag);
}
@ -1144,7 +1159,8 @@ void ThermalController::ctrlIfBoard() {
sensors[2].first = deviceTemperatures.mgm2SideB.isValid();
sensors[2].second = deviceTemperatures.mgm2SideB.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, ifBoardLimits);
HeaterContext htrCtx(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, ifBoardLimits);
ctrlComponentTemperature(htrCtx);
// TODO: special event overheating + could go back to safe mode
}
@ -1157,7 +1173,8 @@ void ThermalController::ctrlTcsBoard() {
sensors[2].first = sensorTemperatures.tmp1075Tcs1.isValid();
sensors[2].second = sensorTemperatures.tmp1075Tcs1.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, tcsBoardLimits);
HeaterContext htrCtx(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, tcsBoardLimits);
ctrlComponentTemperature(htrCtx);
// TODO: special event overheating + could go back to safe mode
}
@ -1170,7 +1187,8 @@ void ThermalController::ctrlObc() {
sensors[2].first = sensorTemperatures.tmp1075Tcs0.isValid();
sensors[2].second = sensorTemperatures.tmp1075Tcs0.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcLimits);
HeaterContext htrCtx(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not obcTooHotFlag) {
triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32());
obcTooHotFlag = true;
@ -1188,7 +1206,8 @@ void ThermalController::ctrlObcIfBoard() {
sensors[2].first = sensorTemperatures.tmp1075Tcs1.isValid();
sensors[2].second = sensorTemperatures.tmp1075Tcs1.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcIfBoardLimits);
HeaterContext htrCtx(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcIfBoardLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not obcTooHotFlag) {
triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32());
obcTooHotFlag = true;
@ -1206,8 +1225,8 @@ void ThermalController::ctrlSBandTransceiver() {
sensors[2].first = sensorTemperatures.payload4kCamera.isValid();
sensors[2].second = sensorTemperatures.payload4kCamera.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA,
sBandTransceiverLimits);
HeaterContext htrCtx(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not syrlinksTooHotFlag) {
triggerEvent(tcsCtrl::SYRLINKS_OVERHEATING, tempFloatToU32());
syrlinksTooHotFlag = true;
@ -1222,7 +1241,8 @@ void ThermalController::ctrlPcduP60Board() {
sensors[1].first = deviceTemperatures.temp2P60dock.isValid();
sensors[1].second = deviceTemperatures.temp2P60dock.value;
numSensors = 2;
ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduP60BoardLimits);
HeaterContext htrCtx(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduP60BoardLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not pcduSystemTooHotFlag) {
triggerEvent(tcsCtrl::PCDU_SYSTEM_OVERHEATING, tempFloatToU32());
pcduSystemTooHotFlag = true;
@ -1252,7 +1272,8 @@ void ThermalController::ctrlPcduAcu() {
sensorTempAvailable = false;
}
if (sensorTempAvailable) {
checkLimitsAndCtrlHeater(switchNr, redSwitchNr, pcduAcuLimits);
HeaterContext htrCtx(switchNr, redSwitchNr, pcduAcuLimits);
checkLimitsAndCtrlHeater(htrCtx);
}
}
if (componentAboveUpperLimit and not pcduSystemTooHotFlag) {
@ -1272,7 +1293,8 @@ void ThermalController::ctrlPcduPdu() {
sensors[2].first = sensorTemperatures.tmp1075Tcs0.isValid();
sensors[2].second = sensorTemperatures.tmp1075Tcs0.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits);
HeaterContext htrCtx(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not pcduSystemTooHotFlag) {
triggerEvent(tcsCtrl::PCDU_SYSTEM_OVERHEATING, tempFloatToU32());
pcduSystemTooHotFlag = true;
@ -1292,7 +1314,8 @@ void ThermalController::ctrlPlPcduBoard() {
sensors[3].first = sensorTemperatures.plpcduHeatspreader.isValid();
sensors[3].second = sensorTemperatures.plpcduHeatspreader.value;
numSensors = 4;
ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, plPcduBoardLimits);
HeaterContext htrCtx(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, plPcduBoardLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1305,8 +1328,9 @@ void ThermalController::ctrlPlocMissionBoard() {
sensors[2].first = sensorTemperatures.dacHeatspreader.isValid();
sensors[2].second = sensorTemperatures.dacHeatspreader.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
HeaterContext htrCtx(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
plocMissionBoardLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLOC_SUPERVISOR_HANDLER, plocTooHotFlag);
}
@ -1319,8 +1343,9 @@ void ThermalController::ctrlPlocProcessingBoard() {
sensors[2].first = sensorTemperatures.dacHeatspreader.isValid();
sensors[2].second = sensorTemperatures.dacHeatspreader.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
HeaterContext htrCtx(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD,
plocProcessingBoardLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLOC_SUPERVISOR_HANDLER, plocTooHotFlag);
}
@ -1333,7 +1358,8 @@ void ThermalController::ctrlDac() {
sensors[2].first = sensorTemperatures.plocHeatspreader.isValid();
sensors[2].second = sensorTemperatures.plocHeatspreader.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, dacLimits);
HeaterContext htrCtx(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, dacLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1346,7 +1372,8 @@ void ThermalController::ctrlCameraBody() {
sensors[2].first = sensorTemperatures.mpa.isValid();
sensors[2].second = sensorTemperatures.mpa.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits);
HeaterContext htrCtx(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits);
ctrlComponentTemperature(htrCtx);
if (componentAboveUpperLimit and not camTooHotOneShotFlag) {
triggerEvent(tcsCtrl::CAMERA_OVERHEATING, tempFloatToU32());
CommandMessage msg;
@ -1371,7 +1398,8 @@ void ThermalController::ctrlDro() {
sensors[2].first = sensorTemperatures.mpa.isValid();
sensors[2].second = sensorTemperatures.mpa.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1384,7 +1412,8 @@ void ThermalController::ctrlX8() {
sensors[2].first = sensorTemperatures.eBandTx.isValid();
sensors[2].second = sensorTemperatures.eBandTx.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1397,7 +1426,8 @@ void ThermalController::ctrlTx() {
sensors[2].first = sensorTemperatures.mpa.isValid();
sensors[2].second = sensorTemperatures.mpa.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1410,7 +1440,8 @@ void ThermalController::ctrlMpa() {
sensors[2].first = sensorTemperatures.eBandTx.isValid();
sensors[2].second = sensorTemperatures.eBandTx.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1423,7 +1454,8 @@ void ThermalController::ctrlHpa() {
sensors[2].first = sensorTemperatures.mpa.isValid();
sensors[2].second = sensorTemperatures.mpa.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, hpaLimits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, hpaLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag);
}
@ -1436,7 +1468,8 @@ void ThermalController::ctrlScexBoard() {
sensors[2].first = sensorTemperatures.hpa.isValid();
sensors[2].second = sensorTemperatures.hpa.value;
numSensors = 3;
ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits);
HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits);
ctrlComponentTemperature(htrCtx);
tooHotHandlerWhichClearsOneShotFlag(objects::SCEX, scexTooHotFlag);
}
@ -1506,18 +1539,16 @@ void ThermalController::performThermalModuleCtrl(const HeaterSwitchStates& heate
heaterTransitionControl(heaterSwitchStates);
}
void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr,
heater::Switchers redSwitchNr,
const TempLimits& tempLimit) {
void ThermalController::ctrlComponentTemperature(HeaterContext& htrCtx) {
if (selectAndReadSensorTemp()) {
if (chooseHeater(switchNr, redSwitchNr)) {
checkLimitsAndCtrlHeater(switchNr, redSwitchNr, tempLimit);
if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) {
checkLimitsAndCtrlHeater(htrCtx);
}
} else {
if (chooseHeater(switchNr,
redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden?
if (heaterHandler.checkSwitchState(switchNr)) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
// TODO: muss der Heater dann wirklich abgeschalten werden?
if (chooseHeater(htrCtx.switchNr, htrCtx.redSwitchNr)) {
if (heaterHandler.getSwitchState(htrCtx.switchNr)) {
heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::OFF);
}
}
}
@ -1562,66 +1593,69 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch
return heaterAvailable;
}
void ThermalController::heaterCtrlTempTooHighHandler(heater::Switchers switchNr,
heater::Switchers redSwitchNr,
const char* whatLimit) {
sif::info << "TCS: Component " << static_cast<int>(thermalComponent) << " too warm" << std::endl;
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF);
heaterStates[switchNr].switchTransition = true;
heaterStates[switchNr].target = HeaterHandler::SwitchState::OFF;
if (heaterHandler.checkSwitchState(redSwitchNr) == HeaterHandler::SwitchState::ON) {
heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF);
heaterStates[redSwitchNr].switchTransition = true;
heaterStates[redSwitchNr].target = HeaterHandler::SwitchState::OFF;
void ThermalController::heaterCtrlTempTooHighHandler(HeaterContext& htrCtx, const char* whatLimit) {
if (htrCtx.switchState == HeaterHandler::SwitchState::ON) {
sif::info << "TCS: Component " << static_cast<int>(thermalComponent) << " too warm, above "
<< whatLimit << ", switching off heater" << std::endl;
heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::OFF);
heaterStates[htrCtx.switchNr].switchTransition = true;
heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::OFF;
}
if (heaterHandler.getSwitchState(htrCtx.redSwitchNr) == HeaterHandler::SwitchState::ON) {
heaterHandler.switchHeater(htrCtx.redSwitchNr, HeaterHandler::SwitchState::OFF);
heaterStates[htrCtx.redSwitchNr].switchTransition = true;
heaterStates[htrCtx.redSwitchNr].target = HeaterHandler::SwitchState::OFF;
}
}
void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
heater::Switchers redSwitchNr,
const TempLimits& tempLimit) {
void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) {
componentAboveCutOffLimit = false;
componentAboveUpperLimit = false;
// Stay passive during switch transitions, wait for heater switching to complete. Otherwise,
// still check whether components are out of range, which might be important information for the
// top level control loop.
if (heaterStates[switchNr].switchTransition) {
heaterCtrlCheckUpperLimits(switchNr, redSwitchNr, false, tempLimit);
if (heaterStates[htrCtx.switchNr].switchTransition) {
sif::debug << " heater in switch transition" << std::endl;
htrCtx.doHeaterHandling = false;
heaterCtrlCheckUpperLimits(htrCtx);
} else {
// Heater off
if (not heaterHandler.checkSwitchState(switchNr)) {
htrCtx.switchState = heaterHandler.getSwitchState(htrCtx.switchNr);
if (htrCtx.switchState == HeaterHandler::SwitchState::OFF) {
// sif::debug << " heater off" << std::endl;
// TODO: check NOP limit and maybe trigger fdir
if (sensorTemp < tempLimit.opLowerLimit) {
heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON);
if (sensorTemp < htrCtx.tempLimit.opLowerLimit) {
heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::ON);
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater "
<< static_cast<int>(thermalComponent) << " ON" << std::endl;
heaterStates[switchNr].switchTransition = true;
heaterStates[htrCtx.switchNr].switchTransition = true;
thermalStates[thermalComponent].heating = true;
heaterStates[switchNr].target = HeaterHandler::SwitchState::ON;
heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::ON;
} else {
thermalStates[thermalComponent].heating = false;
}
heaterCtrlCheckUpperLimits(switchNr, redSwitchNr, true, tempLimit);
heaterCtrlCheckUpperLimits(htrCtx);
// Heater on
} else if (heaterHandler.checkSwitchState(switchNr)) {
} else if (heaterHandler.getSwitchState(htrCtx.switchNr) == HeaterHandler::SwitchState::ON) {
// sif::debug << " heater on" << std::endl;
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);
if (sensorTemp >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET) {
heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::OFF);
sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater "
<< static_cast<int>(thermalComponent) << " OFF" << std::endl;
heaterStates[switchNr].switchTransition = true;
heaterStates[switchNr].target = HeaterHandler::SwitchState::OFF;
heaterStates[htrCtx.switchNr].switchTransition = true;
heaterStates[htrCtx.switchNr].target = HeaterHandler::SwitchState::OFF;
thermalStates[thermalComponent].heating = false;
}
} else {
// This can happen if heater is used as alternative heater (no regular heating cycle), so we
// should still check the upper limits.
bool tooHighHandlerAlreadyCalled =
heaterCtrlCheckUpperLimits(switchNr, redSwitchNr, true, tempLimit);
if (sensorTemp >= tempLimit.cutOffLimit) {
bool tooHighHandlerAlreadyCalled = heaterCtrlCheckUpperLimits(htrCtx);
if (sensorTemp >= htrCtx.tempLimit.cutOffLimit) {
componentAboveCutOffLimit = true;
if (not tooHighHandlerAlreadyCalled) {
heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "CutOff-Limit");
heaterCtrlTempTooHighHandler(htrCtx, "CutOff-Limit");
}
}
}
@ -1629,21 +1663,18 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr,
}
}
bool ThermalController::heaterCtrlCheckUpperLimits(heater::Switchers switchNr,
heater::Switchers redSwitchNr,
bool doHeaterHandling,
const TempLimits& tempLimit) {
if (sensorTemp >= tempLimit.nopUpperLimit) {
bool ThermalController::heaterCtrlCheckUpperLimits(HeaterContext& htrCtx) {
if (sensorTemp >= htrCtx.tempLimit.nopUpperLimit) {
componentAboveUpperLimit = true;
if (doHeaterHandling) {
heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "NOP-Limit");
if (htrCtx.doHeaterHandling) {
heaterCtrlTempTooHighHandler(htrCtx, "NOP-Limit");
}
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH;
return true;
} else if (sensorTemp >= tempLimit.opUpperLimit) {
} else if (sensorTemp >= htrCtx.tempLimit.opUpperLimit) {
componentAboveUpperLimit = true;
if (doHeaterHandling) {
heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "OP-Limit");
if (htrCtx.doHeaterHandling) {
heaterCtrlTempTooHighHandler(htrCtx, "OP-Limit");
}
overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_HIGH;
return true;

View File

@ -97,6 +97,18 @@ class ThermalController : public ExtendedControllerBase {
ReturnValue_t initialize() override;
protected:
struct HeaterContext {
public:
HeaterContext(heater::Switchers switchNr, heater::Switchers redundantSwitchNr,
const TempLimits& tempLimit)
: switchNr(switchNr), redSwitchNr(redundantSwitchNr), tempLimit(tempLimit) {}
bool doHeaterHandling = true;
heater::Switchers switchNr;
HeaterHandler::SwitchState switchState = HeaterHandler::SwitchState::OFF;
heater::Switchers redSwitchNr;
const TempLimits& tempLimit;
};
void performThermalModuleCtrl(const HeaterSwitchStates& heaterSwitchStates);
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void performControlOperation() override;
@ -281,14 +293,10 @@ class ThermalController : public ExtendedControllerBase {
void copySus();
void copyDevices();
void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr,
const TempLimits& tempLimit);
void checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr,
const TempLimits& tempLimit);
bool heaterCtrlCheckUpperLimits(heater::Switchers switchNr, heater::Switchers redSwitchNr,
bool doHeaterHandling, const TempLimits& tempLimit);
void heaterCtrlTempTooHighHandler(heater::Switchers switchNr, heater::Switchers redSwitchNr,
const char* whatLimit);
void ctrlComponentTemperature(HeaterContext& heaterContext);
void checkLimitsAndCtrlHeater(HeaterContext& heaterContext);
bool heaterCtrlCheckUpperLimits(HeaterContext& heaterContext);
void heaterCtrlTempTooHighHandler(HeaterContext& heaterContext, const char* whatLimit);
bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr);
bool selectAndReadSensorTemp();

View File

@ -259,7 +259,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
// Check state of main line switch
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_ON) {
if (checkSwitchState(heaterIdx) == SwitchState::OFF) {
if (getSwitchState(heaterIdx) == SwitchState::OFF) {
gpioId_t gpioId = heater.gpioId;
result = gpioInterface->pullHigh(gpioId);
if (result != returnvalue::OK) {
@ -310,7 +310,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
ReturnValue_t result = returnvalue::OK;
auto& heater = heaterVec.at(heaterIdx);
// Check whether switch is already off
if (checkSwitchState(heaterIdx)) {
if (getSwitchState(heaterIdx)) {
gpioId_t gpioId = heater.gpioId;
result = gpioInterface->pullLow(gpioId);
if (result != returnvalue::OK) {
@ -344,7 +344,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
heater.cmdActive = false;
}
HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) const {
HeaterHandler::SwitchState HeaterHandler::getSwitchState(heater::Switchers switchNr) const {
MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
return heaterVec.at(switchNr).switchState;
}
@ -428,7 +428,7 @@ ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const {
if (switchNr > 7) {
return returnvalue::FAILED;
}
if (checkSwitchState(static_cast<heater::Switchers>(switchNr)) == SwitchState::ON) {
if (getSwitchState(static_cast<heater::Switchers>(switchNr)) == SwitchState::ON) {
return PowerSwitchIF::SWITCH_ON;
}
return PowerSwitchIF::SWITCH_OFF;

View File

@ -174,7 +174,7 @@ class HeaterHandler : public ExecutableObjectIF,
* @brief Returns the state of a switch (ON - true, or OFF - false).
* @param switchNr The number of the switch to check.
*/
SwitchState checkSwitchState(heater::Switchers switchNr) const;
SwitchState getSwitchState(heater::Switchers switchNr) const;
/**
* @brief This function runs commands waiting for execution.