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 *NOT_ENOUGH_DEVICES_DUAL_MODE_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE";
const char *POWER_STATE_MACHINE_TIMEOUT_STRING = "POWER_STATE_MACHINE_TIMEOUT"; 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 *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 *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 *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 *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 *CHILDREN_LOST_MODE_STRING = "CHILDREN_LOST_MODE";
const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE"; const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE";
const char *CANT_GET_FIX_STRING = "CANT_GET_FIX"; 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 *NOT_ENOUGH_DEVICES_DUAL_MODE_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE";
const char *POWER_STATE_MACHINE_TIMEOUT_STRING = "POWER_STATE_MACHINE_TIMEOUT"; 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 *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 *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 *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 *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 *CHILDREN_LOST_MODE_STRING = "CHILDREN_LOST_MODE";
const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE"; const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE";
const char *CANT_GET_FIX_STRING = "CANT_GET_FIX"; const char *CANT_GET_FIX_STRING = "CANT_GET_FIX";

View File

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

View File

@ -97,6 +97,18 @@ class ThermalController : public ExtendedControllerBase {
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
protected: 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); void performThermalModuleCtrl(const HeaterSwitchStates& heaterSwitchStates);
ReturnValue_t handleCommandMessage(CommandMessage* message) override; ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void performControlOperation() override; void performControlOperation() override;
@ -281,14 +293,10 @@ class ThermalController : public ExtendedControllerBase {
void copySus(); void copySus();
void copyDevices(); void copyDevices();
void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, void ctrlComponentTemperature(HeaterContext& heaterContext);
const TempLimits& tempLimit); void checkLimitsAndCtrlHeater(HeaterContext& heaterContext);
void checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, bool heaterCtrlCheckUpperLimits(HeaterContext& heaterContext);
const TempLimits& tempLimit); void heaterCtrlTempTooHighHandler(HeaterContext& heaterContext, const char* whatLimit);
bool heaterCtrlCheckUpperLimits(heater::Switchers switchNr, heater::Switchers redSwitchNr,
bool doHeaterHandling, const TempLimits& tempLimit);
void heaterCtrlTempTooHighHandler(heater::Switchers switchNr, heater::Switchers redSwitchNr,
const char* whatLimit);
bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr);
bool selectAndReadSensorTemp(); bool selectAndReadSensorTemp();

View File

@ -259,7 +259,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
// Check state of main line switch // Check state of main line switch
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { if (mainSwitchState == PowerSwitchIF::SWITCH_ON) {
if (checkSwitchState(heaterIdx) == SwitchState::OFF) { if (getSwitchState(heaterIdx) == SwitchState::OFF) {
gpioId_t gpioId = heater.gpioId; gpioId_t gpioId = heater.gpioId;
result = gpioInterface->pullHigh(gpioId); result = gpioInterface->pullHigh(gpioId);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -310,7 +310,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
auto& heater = heaterVec.at(heaterIdx); auto& heater = heaterVec.at(heaterIdx);
// Check whether switch is already off // Check whether switch is already off
if (checkSwitchState(heaterIdx)) { if (getSwitchState(heaterIdx)) {
gpioId_t gpioId = heater.gpioId; gpioId_t gpioId = heater.gpioId;
result = gpioInterface->pullLow(gpioId); result = gpioInterface->pullLow(gpioId);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -344,7 +344,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
heater.cmdActive = false; 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); MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
return heaterVec.at(switchNr).switchState; return heaterVec.at(switchNr).switchState;
} }
@ -428,7 +428,7 @@ ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const {
if (switchNr > 7) { if (switchNr > 7) {
return returnvalue::FAILED; 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_ON;
} }
return PowerSwitchIF::SWITCH_OFF; 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). * @brief Returns the state of a switch (ON - true, or OFF - false).
* @param switchNr The number of the switch to check. * @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. * @brief This function runs commands waiting for execution.