From 77b7433caf90932ede9dd029039495d16e08bb93 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 10 Feb 2023 12:18:16 +0100 Subject: [PATCH 01/51] enum ThermalComponents --- mission/controller/ThermalController.cpp | 57 +++++++++++++++++------- mission/controller/ThermalController.h | 28 ++++++++++++ 2 files changed, 70 insertions(+), 15 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 947119ad..44ce9806 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -109,7 +109,7 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } - //performThermalModuleCtrl(); + // performThermalModuleCtrl(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -966,6 +966,7 @@ void ThermalController::ctrlAcsBoard() { heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; // A side + thermalComponent = acsBoard; sensors[0].first = deviceTemperatures.gyro0SideA.isValid(); sensors[0].second = deviceTemperatures.gyro0SideA.value; sensors[1].first = deviceTemperatures.mgm0SideA.isValid(); @@ -1008,6 +1009,7 @@ void ThermalController::ctrlAcsBoard() { } void ThermalController::ctrlMgt() { + thermalComponent = mgt; PoolReadGuard pg(&imtqThermalSet); auto heaterReq = static_cast(imtqThermalSet.heaterRequest.value); @@ -1027,6 +1029,7 @@ void ThermalController::ctrlMgt() { void ThermalController::ctrlRw() { // TODO: better solution? // RW1 + thermalComponent = rw; sensors[0].first = sensorTemperatures.sensor_rw1.isValid(); sensors[0].second = sensorTemperatures.sensor_rw1.value; sensors[1].first = deviceTemperatures.rw1.isValid(); @@ -1039,6 +1042,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW2 + thermalComponent = rw; sensors[0].first = deviceTemperatures.rw2.isValid(); sensors[0].second = deviceTemperatures.rw2.value; sensors[1].first = deviceTemperatures.rw3.isValid(); @@ -1051,6 +1055,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW3 + thermalComponent = rw; sensors[0].first = deviceTemperatures.rw3.isValid(); sensors[0].second = deviceTemperatures.rw3.value; sensors[1].first = deviceTemperatures.rw4.isValid(); @@ -1063,6 +1068,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW4 + thermalComponent = rw; sensors[0].first = deviceTemperatures.rw4.isValid(); sensors[0].second = deviceTemperatures.rw4.value; sensors[1].first = deviceTemperatures.rw1.isValid(); @@ -1076,6 +1082,7 @@ void ThermalController::ctrlRw() { } void ThermalController::ctrlStr() { + thermalComponent = str; sensors[0].first = sensorTemperatures.sensor_startracker.isValid(); sensors[0].second = sensorTemperatures.sensor_startracker.value; sensors[1].first = deviceTemperatures.startracker.isValid(); @@ -1087,6 +1094,7 @@ void ThermalController::ctrlStr() { } void ThermalController::ctrlIfBoard() { + thermalComponent = ifBoard; sensors[0].first = sensorTemperatures.tmp1075IfBrd.isValid(); sensors[0].second = sensorTemperatures.tmp1075IfBrd.value; sensors[1].first = sensorTemperatures.sensor_magnettorquer.isValid(); @@ -1098,6 +1106,7 @@ void ThermalController::ctrlIfBoard() { } void ThermalController::ctrlTcsBoard() { + thermalComponent = tcsBoard; sensors[0].first = sensorTemperatures.sensor_tcs_board.isValid(); sensors[0].second = sensorTemperatures.sensor_tcs_board.value; sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); @@ -1109,6 +1118,7 @@ void ThermalController::ctrlTcsBoard() { } void ThermalController::ctrlObc() { + thermalComponent = obc; sensors[0].first = deviceTemperatures.q7s.isValid(); sensors[0].second = deviceTemperatures.q7s.value; sensors[1].first = sensorTemperatures.tmp1075Tcs1.isValid(); @@ -1123,6 +1133,7 @@ void ThermalController::ctrlObc() { } void ThermalController::ctrlObcIfBoard() { + thermalComponent = obcIfBoard; sensors[0].first = deviceTemperatures.q7s.isValid(); sensors[0].second = deviceTemperatures.q7s.value; sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); @@ -1134,6 +1145,7 @@ void ThermalController::ctrlObcIfBoard() { } void ThermalController::ctrlSBandTransceiver() { + thermalComponent = sBandTransceiver; sensors[0].first = deviceTemperatures.syrlinksPowerAmplifier.isValid(); sensors[0].second = deviceTemperatures.syrlinksPowerAmplifier.value; sensors[1].first = deviceTemperatures.syrlinksBasebandBoard.isValid(); @@ -1148,6 +1160,7 @@ void ThermalController::ctrlSBandTransceiver() { } } void ThermalController::ctrlPcduP60Board() { + thermalComponent = pcduP60Board; sensors[0].first = deviceTemperatures.temp1P60dock.isValid(); sensors[0].second = deviceTemperatures.temp1P60dock.value; sensors[1].first = deviceTemperatures.temp2P60dock.isValid(); @@ -1157,6 +1170,7 @@ void ThermalController::ctrlPcduP60Board() { } void ThermalController::ctrlPcduAcu() { + thermalComponent = pcduAcu; heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; @@ -1172,7 +1186,7 @@ void ThermalController::ctrlPcduAcu() { } else if (sensorTemperatures.sensor_acu.isValid()) { sensorTemp = sensorTemperatures.sensor_acu.value; } else { - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); sensorTempAvailable = false; } if (sensorTempAvailable) { @@ -1182,6 +1196,7 @@ void ThermalController::ctrlPcduAcu() { } void ThermalController::ctrlPcduPdu() { + thermalComponent = pcduPdu; sensors[0].first = deviceTemperatures.pdu1.isValid(); sensors[0].second = deviceTemperatures.pdu1.value; sensors[1].first = deviceTemperatures.pdu2.isValid(); @@ -1193,6 +1208,7 @@ void ThermalController::ctrlPcduPdu() { } void ThermalController::ctrlPlPcduBoard() { + thermalComponent = plPcduBoard; sensors[0].first = sensorTemperatures.tmp1075PlPcdu0.isValid(); sensors[0].second = sensorTemperatures.tmp1075PlPcdu0.value; sensors[1].first = sensorTemperatures.tmp1075PlPcdu1.isValid(); @@ -1209,6 +1225,7 @@ void ThermalController::ctrlPlPcduBoard() { } void ThermalController::ctrlPlocMissionBoard() { + thermalComponent = plocMissionBoard; sensors[0].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); sensors[0].second = sensorTemperatures.sensor_ploc_heatspreader.value; sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); @@ -1224,6 +1241,7 @@ void ThermalController::ctrlPlocMissionBoard() { } void ThermalController::ctrlPlocProcessingBoard() { + thermalComponent = plocProcessingBoard; sensors[0].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); sensors[0].second = sensorTemperatures.sensor_ploc_missionboard.value; sensors[1].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); @@ -1236,6 +1254,7 @@ void ThermalController::ctrlPlocProcessingBoard() { } void ThermalController::ctrlDac() { + thermalComponent = dac; sensors[0].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); sensors[0].second = sensorTemperatures.sensor_dac_heatspreader.value; sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); @@ -1247,6 +1266,7 @@ void ThermalController::ctrlDac() { } void ThermalController::ctrlCameraBody() { + thermalComponent = camera; sensors[0].first = sensorTemperatures.sensor_4k_camera.isValid(); sensors[0].second = sensorTemperatures.sensor_4k_camera.value; sensors[1].first = sensorTemperatures.sensor_dro.isValid(); @@ -1258,6 +1278,7 @@ void ThermalController::ctrlCameraBody() { } void ThermalController::ctrlDro() { + thermalComponent = dro; sensors[0].first = sensorTemperatures.sensor_dro.isValid(); sensors[0].second = sensorTemperatures.sensor_dro.value; sensors[1].first = sensorTemperatures.sensor_4k_camera.isValid(); @@ -1269,6 +1290,7 @@ void ThermalController::ctrlDro() { } void ThermalController::ctrlX8() { + thermalComponent = x8; sensors[0].first = sensorTemperatures.sensor_x8.isValid(); sensors[0].second = sensorTemperatures.sensor_x8.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); @@ -1280,6 +1302,7 @@ void ThermalController::ctrlX8() { } void ThermalController::ctrlTx() { + thermalComponent = tx; sensors[0].first = sensorTemperatures.sensor_tx_modul.isValid(); sensors[0].second = sensorTemperatures.sensor_tx_modul.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); @@ -1291,6 +1314,7 @@ void ThermalController::ctrlTx() { } void ThermalController::ctrlMpa() { + thermalComponent = mpa; sensors[0].first = sensorTemperatures.sensor_mpa.isValid(); sensors[0].second = sensorTemperatures.sensor_mpa.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); @@ -1302,6 +1326,7 @@ void ThermalController::ctrlMpa() { } void ThermalController::ctrlHpa() { + thermalComponent = hpa; sensors[0].first = sensorTemperatures.sensor_hpa.isValid(); sensors[0].second = sensorTemperatures.sensor_hpa.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); @@ -1315,6 +1340,18 @@ void ThermalController::ctrlHpa() { } } +void ThermalController::ctrlScexBoard() { + thermalComponent = scexBoard; + sensors[0].first = sensorTemperatures.sensor_scex.isValid(); + sensors[0].second = sensorTemperatures.sensor_scex.value; + sensors[1].first = sensorTemperatures.sensor_x8.isValid(); + sensors[1].second = sensorTemperatures.sensor_x8.value; + sensors[2].first = sensorTemperatures.sensor_hpa.isValid(); + sensors[2].second = sensorTemperatures.sensor_hpa.value; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); +} + void ThermalController::performThermalModuleCtrl() { ctrlCameraBody(); ctrlAcsBoard(); @@ -1325,6 +1362,7 @@ void ThermalController::performThermalModuleCtrl() { ctrlAcsBoard(); ctrlObc(); ctrlObcIfBoard(); + ctrlTcsBoard(); // Todo: warum wurde das weggelassen? ctrlSBandTransceiver(); ctrlPcduP60Board(); ctrlPcduAcu(); @@ -1333,7 +1371,6 @@ void ThermalController::performThermalModuleCtrl() { ctrlPlocMissionBoard(); ctrlPlocProcessingBoard(); ctrlDac(); - ctrlDro(); ctrlX8(); ctrlHpa(); @@ -1342,17 +1379,6 @@ void ThermalController::performThermalModuleCtrl() { ctrlScexBoard(); } -void ThermalController::ctrlScexBoard() { - sensors[0].first = sensorTemperatures.sensor_scex.isValid(); - sensors[0].second = sensorTemperatures.sensor_scex.value; - sensors[1].first = sensorTemperatures.sensor_x8.isValid(); - sensors[1].second = sensorTemperatures.sensor_x8.value; - sensors[2].first = sensorTemperatures.sensor_hpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_hpa.value; - numSensors = 3; - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); -} - void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; @@ -1403,7 +1429,7 @@ bool ThermalController::selectAndReadSensorTemp() { return true; } } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE); + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); return false; } @@ -1432,4 +1458,5 @@ void ThermalController::resetSensorsArray() { validValuePair.first = false; validValuePair.second = INVALID_TEMPERATURE; } + thermalComponent = none; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 03c7954c..c3c09913 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -34,6 +34,33 @@ struct TempLimits { float nopUpperLimit; }; +enum ThermalComponents { + none, + acsBoard, + mgt, + rw, + str, + ifBoard, + tcsBoard, + obc, + obcIfBoard, + sBandTransceiver, + pcduP60Board, + pcduAcu, + pcduPdu, + plPcduBoard, + plocMissionBoard, + plocProcessingBoard, + dac, + camera, + dro, + x8, + hpa, + tx, + mpa, + scexBoard +}; + class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; @@ -146,6 +173,7 @@ class ThermalController : public ExtendedControllerBase { TempLimits scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0); double sensorTemp = INVALID_TEMPERATURE; + ThermalComponents thermalComponent = none; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; -- 2.43.0 From 9b849d10e9e5480128f2834a1dddf72cec425689 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 21 Feb 2023 17:49:55 +0100 Subject: [PATCH 02/51] small changes --- mission/controller/ThermalController.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 44ce9806..28948514 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -109,7 +109,7 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } - // performThermalModuleCtrl(); + performThermalModuleCtrl(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -993,6 +993,7 @@ void ThermalController::ctrlAcsBoard() { sensors[2].second = deviceTemperatures.gyro3SideB.value; sensors[3].first = sensorTemperatures.sensor_tcs_board.isValid(); sensors[3].second = sensorTemperatures.sensor_tcs_board.value; + numSensors = 4; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); @@ -1177,7 +1178,7 @@ void ThermalController::ctrlPcduAcu() { if (chooseHeater(switchNr, redSwitchNr)) { bool sensorTempAvailable = true; - if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { + if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { //TODO: war invalid aber Wert 0 stat 999 sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[1]; @@ -1203,7 +1204,7 @@ void ThermalController::ctrlPcduPdu() { sensors[1].second = deviceTemperatures.pdu2.value; sensors[2].first = sensorTemperatures.tmp1075Tcs0.isValid(); sensors[2].second = sensorTemperatures.tmp1075Tcs0.value; - numSensors = 2; + numSensors = 3; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits); } @@ -1353,16 +1354,14 @@ void ThermalController::ctrlScexBoard() { } void ThermalController::performThermalModuleCtrl() { - ctrlCameraBody(); ctrlAcsBoard(); ctrlMgt(); ctrlRw(); ctrlStr(); ctrlIfBoard(); - ctrlAcsBoard(); + ctrlTcsBoard(); ctrlObc(); ctrlObcIfBoard(); - ctrlTcsBoard(); // Todo: warum wurde das weggelassen? ctrlSBandTransceiver(); ctrlPcduP60Board(); ctrlPcduAcu(); @@ -1371,6 +1370,7 @@ void ThermalController::performThermalModuleCtrl() { ctrlPlocMissionBoard(); ctrlPlocProcessingBoard(); ctrlDac(); + ctrlCameraBody(); ctrlDro(); ctrlX8(); ctrlHpa(); -- 2.43.0 From e13636167fddbf2a7dd44c59db51e332cdb8f085 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 22 Feb 2023 17:30:30 +0100 Subject: [PATCH 03/51] limit for error events thermalcontroller + dummy beta --- bsp_hosted/scheduling.cpp | 3 +- dummies/Max31865Dummy.cpp | 10 ++++- dummies/Max31865Dummy.h | 2 +- dummies/P60DockDummy.cpp | 6 ++- dummies/P60DockDummy.h | 3 ++ dummies/TemperatureSensorInserter.cpp | 19 +++++++- dummies/TemperatureSensorInserter.h | 2 + dummies/Tmp1075Dummy.cpp | 6 +++ dummies/Tmp1075Dummy.h | 1 + dummies/helpers.cpp | 1 + mission/controller/ThermalController.cpp | 48 +++++++++++++-------- mission/controller/ThermalController.h | 55 +++++++++++++----------- 12 files changed, 106 insertions(+), 50 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 843b2892..89711fa0 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -186,7 +186,8 @@ void scheduling::initTasks() { #endif /* OBSW_ADD_TEST_CODE == 1 */ PeriodicTaskIF* dummyTask = factory->createPeriodicTask( - "DUMMY_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + "DUMMY_TASK", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + dummyTask->addComponent(objects::THERMAL_TEMP_INSERTER); scheduling::scheduleTmpTempSensors(dummyTask); scheduling::scheduleRtdSensors(dummyTask); dummyTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF); diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index 43198bba..e893fe1c 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -1,5 +1,7 @@ #include "Max31865Dummy.h" +#include "fsfw/datapool/PoolReadGuard.h" + using namespace returnvalue; Max31865Dummy::Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) @@ -35,8 +37,12 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD return OK; } -void Max31865Dummy::setTemperature(float temperature) { - set.temperatureCelcius.value = temperature; +void Max31865Dummy::setTemperature(float temperature, bool valid) { + PoolReadGuard pg(&set); + if(pg.getReadResult() == returnvalue::OK) { + set.temperatureCelcius.value = temperature; + set.setValidity(valid, true); + } } LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index 79f4ddb4..0f549b49 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -9,7 +9,7 @@ class Max31865Dummy : public DeviceHandlerBase { Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); Max31865Dummy(object_id_t objectId, CookieIF *comCookie); - void setTemperature(float temperature); + void setTemperature(float temperature, bool setValid); private: MAX31865::PrimarySet set; diff --git a/dummies/P60DockDummy.cpp b/dummies/P60DockDummy.cpp index 8a3611ca..8ae769ef 100644 --- a/dummies/P60DockDummy.cpp +++ b/dummies/P60DockDummy.cpp @@ -2,6 +2,8 @@ #include +#include "fsfw/datapool/PoolReadGuard.h" + P60DockDummy::P60DockDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie) {} @@ -40,7 +42,7 @@ uint32_t P60DockDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { re ReturnValue_t P60DockDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(P60Dock::pool::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); - localDataPoolMap.emplace(P60Dock::pool::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60Dock::pool::P60DOCK_TEMPERATURE_1, new PoolEntry({10}, true)); + localDataPoolMap.emplace(P60Dock::pool::P60DOCK_TEMPERATURE_2, new PoolEntry({10}, true)); return returnvalue::OK; } diff --git a/dummies/P60DockDummy.h b/dummies/P60DockDummy.h index 9b67b155..235aa885 100644 --- a/dummies/P60DockDummy.h +++ b/dummies/P60DockDummy.h @@ -2,6 +2,7 @@ #define DUMMIES_P60DOCKDUMMY_H_ #include +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" class P60DockDummy : public DeviceHandlerBase { public: @@ -15,6 +16,8 @@ class P60DockDummy : public DeviceHandlerBase { virtual ~P60DockDummy(); protected: + lp_var_t temp1 = lp_var_t(this, P60Dock::pool::P60DOCK_TEMPERATURE_1); + lp_var_t temp2 = lp_var_t(this, P60Dock::pool::P60DOCK_TEMPERATURE_2); void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index c75b008c..ac94deb7 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -9,12 +9,14 @@ TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId, Max31865DummyMap tempSensorDummies_, Tmp1075DummyMap tempTmpSensorDummies_) - : SystemObject(objects::THERMAL_TEMP_INSERTER), + : SystemObject(objectId), max31865DummyMap(std::move(tempSensorDummies_)), tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {} ReturnValue_t TemperatureSensorInserter::initialize() { + if (performTest) { + if (testCase == TestCase::COOL_SYRLINKS) { } } @@ -22,6 +24,17 @@ ReturnValue_t TemperatureSensorInserter::initialize() { } ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { + if(not tempsWereInitialized) { + for(auto& rtdDummy: max31865DummyMap) { + rtdDummy.second->setTemperature(10, true); + } + for(auto& tmpDummy: tmp1075DummyMap) { + tmpDummy.second->setTemperature(10, true); + } + tempsWereInitialized = true; + } + + /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { @@ -38,3 +51,7 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { */ return returnvalue::OK; } +ReturnValue_t TemperatureSensorInserter::initializeAfterTaskCreation() { + + return returnvalue::OK; +} diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 33d61443..d1ccf0a2 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -14,6 +14,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject Tmp1075DummyMap tempTmpSensorDummies_); ReturnValue_t initialize() override; + ReturnValue_t initializeAfterTaskCreation() override; protected: ReturnValue_t performOperation(uint8_t opCode) override; @@ -23,6 +24,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject Tmp1075DummyMap tmp1075DummyMap; enum TestCase { NONE = 0, COOL_SYRLINKS = 1 }; int iteration = 0; + bool tempsWereInitialized = false; bool performTest = false; TestCase testCase = TestCase::NONE; diff --git a/dummies/Tmp1075Dummy.cpp b/dummies/Tmp1075Dummy.cpp index 9715a346..1f05c29b 100644 --- a/dummies/Tmp1075Dummy.cpp +++ b/dummies/Tmp1075Dummy.cpp @@ -1,5 +1,6 @@ #include "Tmp1075Dummy.h" +#include "fsfw/datapool/PoolReadGuard.h" #include "mission/devices/devicedefinitions/Tmp1075Definitions.h" using namespace returnvalue; @@ -24,6 +25,11 @@ ReturnValue_t Tmp1075Dummy::scanForReply(const uint8_t *start, size_t len, ReturnValue_t Tmp1075Dummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { return 0; } +void Tmp1075Dummy::setTemperature(float temperature, bool valid) { + PoolReadGuard pg(&set); + set.temperatureCelcius.value = temperature; + set.setValidity(valid, true); +} void Tmp1075Dummy::fillCommandAndReplyMap() {} uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } ReturnValue_t Tmp1075Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, diff --git a/dummies/Tmp1075Dummy.h b/dummies/Tmp1075Dummy.h index e43ca8e2..1b9373ad 100644 --- a/dummies/Tmp1075Dummy.h +++ b/dummies/Tmp1075Dummy.h @@ -7,6 +7,7 @@ class Tmp1075Dummy : public DeviceHandlerBase { public: Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + void setTemperature(float temperature, bool setValid); private: TMP1075::Tmp1075Dataset set; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index adcb82bb..d7f388fa 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -150,6 +150,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { objects::TMP1075_HANDLER_IF_BOARD, new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, tempTmpSensorDummies); } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 28948514..b75403bf 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -91,22 +91,23 @@ void ThermalController::performControlOperation() { break; } - ReturnValue_t result = sensorTemperatures.read(); - if (result == returnvalue::OK) { - copySensors(); - sensorTemperatures.commit(); + { + PoolReadGuard pg(&sensorTemperatures); + if (pg.getReadResult() == returnvalue::OK) { + copySensors(); + } } - - result = susTemperatures.read(); - if (result == returnvalue::OK) { - copySus(); - susTemperatures.commit(); + { + PoolReadGuard pg(&susTemperatures); + if (pg.getReadResult() == returnvalue::OK) { + copySus(); + } } - - result = deviceTemperatures.read(); - if (result == returnvalue::OK) { - copyDevices(); - deviceTemperatures.commit(); + { + PoolReadGuard pg(&deviceTemperatures); + if (pg.getReadResult() == returnvalue::OK) { + copyDevices(); + } } performThermalModuleCtrl(); @@ -1178,7 +1179,8 @@ void ThermalController::ctrlPcduAcu() { if (chooseHeater(switchNr, redSwitchNr)) { bool sensorTempAvailable = true; - if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { //TODO: war invalid aber Wert 0 stat 999 + if (deviceTemperatures.acu.value[0] != + INVALID_TEMPERATURE) { // TODO: war invalid aber Wert 0 stat 999 sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[1]; @@ -1426,10 +1428,22 @@ bool ThermalController::selectAndReadSensorTemp() { for (unsigned i = 0; i < numSensors; i++) { if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { sensorTemp = sensors[i].second; + errorCounters[thermalComponent] = 0; return true; } } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + + errorCounters[thermalComponent] ++; + if(thermalComponent != rw and thermalComponent != acsBoard){ + if (errorCounters[thermalComponent] <= 3){ + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + } + }else{ + if (errorCounters[thermalComponent] <= 8){ + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + } + } + return false; } @@ -1458,5 +1472,5 @@ void ThermalController::resetSensorsArray() { validValuePair.first = false; validValuePair.second = INVALID_TEMPERATURE; } - thermalComponent = none; + thermalComponent = NONE; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index c3c09913..6c680e20 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -34,31 +34,33 @@ struct TempLimits { float nopUpperLimit; }; -enum ThermalComponents { - none, - acsBoard, - mgt, - rw, - str, - ifBoard, - tcsBoard, - obc, - obcIfBoard, - sBandTransceiver, - pcduP60Board, - pcduAcu, - pcduPdu, - plPcduBoard, - plocMissionBoard, - plocProcessingBoard, - dac, - camera, - dro, - x8, - hpa, - tx, - mpa, - scexBoard +enum ThermalComponents: uint8_t { + //TODO: Großbuchstaben + NONE = 0, + acsBoard = 1, + mgt = 2, + rw = 3, + str = 4, + ifBoard = 5, + tcsBoard = 6, + obc = 7, + obcIfBoard = 8, + sBandTransceiver = 9, + pcduP60Board = 10, + pcduAcu = 11, + pcduPdu = 12, + plPcduBoard = 13, + plocMissionBoard = 14, + plocProcessingBoard = 15, + dac = 16, + camera = 17, + dro = 18, + x8 = 19, + hpa = 20, + tx = 21, + mpa = 22, + scexBoard = 23, + NUM_ENTRIES }; class ThermalController : public ExtendedControllerBase { @@ -173,9 +175,10 @@ class ThermalController : public ExtendedControllerBase { TempLimits scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0); double sensorTemp = INVALID_TEMPERATURE; - ThermalComponents thermalComponent = none; + ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; + uint8_t errorCounters[32]; // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); -- 2.43.0 From b9a6425078fd040f42ee58c5d8d61966ea3f68d0 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 22 Feb 2023 17:50:03 +0100 Subject: [PATCH 04/51] dummy change --- bsp_hosted/scheduling.cpp | 4 ++++ dummies/TemperatureSensorInserter.cpp | 5 ++++- dummies/TemperatureSensorInserter.h | 1 + mission/controller/ThermalController.cpp | 1 + mission/devices/HeaterHandler.cpp | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 89711fa0..0434862c 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -158,6 +158,10 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("THERMAL_CONTROLLER", objects::THERMAL_CONTROLLER); } + result = thermalTask->addComponent(objects::HEATER_HANDLER); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("HEATER_HANDLER", objects::HEATER_HANDLER); + } FixedTimeslotTaskIF* pstTask = factory->createFixedTimeslotTask( "DUMMY_PST", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index ac94deb7..eb9afc12 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -34,7 +34,9 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { tempsWereInitialized = true; } - + if(cycles == 10) { + max31865DummyMap[objects::RTD_14_IC17_TCS_BOARD]->setTemperature(-100, true); + } /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { @@ -49,6 +51,7 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { } max31865PlocHeatspreaderSet.commit(); */ + cycles++; return returnvalue::OK; } ReturnValue_t TemperatureSensorInserter::initializeAfterTaskCreation() { diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index d1ccf0a2..bb0f4ed0 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -24,6 +24,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject Tmp1075DummyMap tmp1075DummyMap; enum TestCase { NONE = 0, COOL_SYRLINKS = 1 }; int iteration = 0; + uint32_t cycles = 0; bool tempsWereInitialized = false; bool performTest = false; TestCase testCase = TestCase::NONE; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b75403bf..6ceef73d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1389,6 +1389,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; + //TODO: EVENT } // Heater on } else if (heaterHandler.checkSwitchState(switchNr)) { diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 43f53bf7..4ff66f7d 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -37,7 +37,7 @@ HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, H cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } -HeaterHandler::~HeaterHandler() {} +HeaterHandler::~HeaterHandler() = default; ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { try { -- 2.43.0 From 0fa1bab94d2e468f956acd16b7487f0073fd1460 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 22 Feb 2023 19:14:35 +0100 Subject: [PATCH 05/51] comments --- bsp_hosted/ObjectFactory.cpp | 7 +++++++ dummies/PduDummy.cpp | 1 + mission/controller/ThermalController.cpp | 20 ++++++++++++-------- mission/controller/ThermalController.h | 9 ++++++++- mission/devices/HeaterHandler.cpp | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index d2c3c3da..287ecd36 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,6 +1,7 @@ #include "ObjectFactory.h" #include +#include "fsfw/power/PowerSwitchIF.h" #include #include #include @@ -62,6 +63,12 @@ void ObjectFactory::produce(void* args) { auto* dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); + std::vector switcherList; + auto initVal = PowerSwitchIF::SWITCH_OFF; + for (unsigned i = 0; i < 18; i++) { + switcherList.emplace_back(initVal); + } + dummySwitcher->setInitialSwitcherList(switcherList); #ifdef PLATFORM_UNIX new SerialComIF(objects::UART_COM_IF); #if OBSW_ADD_PLOC_MPSOC == 1 diff --git a/dummies/PduDummy.cpp b/dummies/PduDummy.cpp index 1c26728c..ed0485ce 100644 --- a/dummies/PduDummy.cpp +++ b/dummies/PduDummy.cpp @@ -38,5 +38,6 @@ uint32_t PduDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return ReturnValue_t PduDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(PDU::pool::PDU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(PDU::pool::PDU_CURRENTS, new PoolEntry(9)); return returnvalue::OK; } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index cbba6a87..5d929503 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1373,19 +1373,23 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; // Heater off - if (not heaterHandler.checkSwitchState(switchNr)) { + if (not heaterHandler.checkSwitchState(switchNr) and not thermalStates[thermalComponent].heating) { if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; + thermalStates[thermalComponent].heating = true; //TODO: EVENT + //TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in transition dann paar mal skippen mit transitionboolean; bool switchOnTransition und bool switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool clearen, falls drei erreicht heaterControlErrorCounter global zählen } // Heater on - } else if (heaterHandler.checkSwitchState(switchNr)) { + } else if (heaterHandler.checkSwitchState(switchNr) and thermalStates[thermalComponent].heating) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; //TODO: array mit struct enthält infos + thermalStates[thermalComponent].heating = false; + } - } else if (not redSwitchNrInUse) { + } else if (redSwitchNrInUse) { if (heaterHandler.checkSwitchState(redSwitchNr)) { if (sensorTemp >= tempLimit.cutOffLimit) { componentAboveCutOffLimit = true; @@ -1417,18 +1421,18 @@ bool ThermalController::selectAndReadSensorTemp() { for (unsigned i = 0; i < numSensors; i++) { if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { sensorTemp = sensors[i].second; - errorCounters[thermalComponent] = 0; + thermalStates[thermalComponent].errorCounter = 0; return true; } } - errorCounters[thermalComponent] ++; + thermalStates[thermalComponent].errorCounter ++; if(thermalComponent != rw and thermalComponent != acsBoard){ - if (errorCounters[thermalComponent] <= 3){ + if (thermalStates[thermalComponent].errorCounter <= 3){ triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } }else{ - if (errorCounters[thermalComponent] <= 8){ + if (thermalStates[thermalComponent].errorCounter <= 8){ triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 368508ab..590565c5 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -36,6 +36,12 @@ struct TempLimits { float nopUpperLimit; }; +struct ThermalState { + uint8_t errorCounter; + bool heating; + uint32_t heaterStartTime; +}; + enum ThermalComponents: uint8_t { //TODO: Großbuchstaben NONE = 0, @@ -183,7 +189,8 @@ class ThermalController : public ExtendedControllerBase { ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; - uint8_t errorCounters[32]; + std::array thermalStates {}; + // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 35287ed7..3b5c865e 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -298,7 +298,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { heater.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); heater.waitMainSwitchOn = true; } else { - sif::debug << "HeaterHandler::handleSwitchHandling: Failed to get state of" + sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to get state of" << " main line switch" << std::endl; if (heater.replyQueue != commandQueue->getId()) { actionHelper.finish(false, heater.replyQueue, heater.action, mainSwitchState); -- 2.43.0 From 9a7779cffb97896714509e8fdbc84b487b5b826e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 22 Feb 2023 21:46:56 +0100 Subject: [PATCH 06/51] struct heaterStates and more --- bsp_hosted/ObjectFactory.cpp | 2 +- dummies/Max31865Dummy.cpp | 2 +- dummies/P60DockDummy.h | 1 + dummies/TemperatureSensorInserter.cpp | 17 +- linux/devices/CMakeLists.txt | 5 +- mission/controller/ThermalController.cpp | 223 +++++++++++++---------- mission/controller/ThermalController.h | 20 +- mission/devices/GyroADIS1650XHandler.cpp | 3 +- mission/devices/ImtqHandler.cpp | 2 +- mission/tmtc/CfdpTmFunnel.cpp | 2 +- mission/tmtc/PusTmFunnel.cpp | 2 +- mission/tmtc/VirtualChannel.cpp | 2 +- 12 files changed, 159 insertions(+), 122 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 287ecd36..33b22f07 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,7 +1,6 @@ #include "ObjectFactory.h" #include -#include "fsfw/power/PowerSwitchIF.h" #include #include #include @@ -11,6 +10,7 @@ #include "OBSWConfig.h" #include "fsfw/platform.h" +#include "fsfw/power/PowerSwitchIF.h" #include "fsfw_tests/integration/task/TestTask.h" #if OBSW_ADD_TMTC_UDP_SERVER == 1 diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index e893fe1c..ae4026ba 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -39,7 +39,7 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD void Max31865Dummy::setTemperature(float temperature, bool valid) { PoolReadGuard pg(&set); - if(pg.getReadResult() == returnvalue::OK) { + if (pg.getReadResult() == returnvalue::OK) { set.temperatureCelcius.value = temperature; set.setValidity(valid, true); } diff --git a/dummies/P60DockDummy.h b/dummies/P60DockDummy.h index 235aa885..1ecbe9ee 100644 --- a/dummies/P60DockDummy.h +++ b/dummies/P60DockDummy.h @@ -2,6 +2,7 @@ #define DUMMIES_P60DOCKDUMMY_H_ #include + #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" class P60DockDummy : public DeviceHandlerBase { diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index eb9afc12..e734b770 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -14,9 +14,7 @@ TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId, tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {} ReturnValue_t TemperatureSensorInserter::initialize() { - if (performTest) { - if (testCase == TestCase::COOL_SYRLINKS) { } } @@ -24,18 +22,18 @@ ReturnValue_t TemperatureSensorInserter::initialize() { } ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { - if(not tempsWereInitialized) { - for(auto& rtdDummy: max31865DummyMap) { + if (not tempsWereInitialized) { + for (auto& rtdDummy : max31865DummyMap) { rtdDummy.second->setTemperature(10, true); } - for(auto& tmpDummy: tmp1075DummyMap) { + for (auto& tmpDummy : tmp1075DummyMap) { tmpDummy.second->setTemperature(10, true); } tempsWereInitialized = true; } - if(cycles == 10) { - max31865DummyMap[objects::RTD_14_IC17_TCS_BOARD]->setTemperature(-100, true); + if (cycles == 10) { + max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(-100, true); } /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); @@ -54,7 +52,4 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { cycles++; return returnvalue::OK; } -ReturnValue_t TemperatureSensorInserter::initializeAfterTaskCreation() { - - return returnvalue::OK; -} +ReturnValue_t TemperatureSensorInserter::initializeAfterTaskCreation() { return returnvalue::OK; } diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 17d842ea..22b39840 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -3,8 +3,9 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) endif() target_sources( - ${OBSW_NAME} PRIVATE Max31865RtdPolling.cpp ScexUartReader.cpp ImtqPollingTask.cpp - ScexDleParser.cpp ScexHelper.cpp RwPollingTask.cpp) + ${OBSW_NAME} + PRIVATE Max31865RtdPolling.cpp ScexUartReader.cpp ImtqPollingTask.cpp + ScexDleParser.cpp ScexHelper.cpp RwPollingTask.cpp) add_subdirectory(ploc) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 5d929503..de6b0023 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1344,102 +1344,31 @@ void ThermalController::ctrlScexBoard() { } void ThermalController::performThermalModuleCtrl() { - ctrlAcsBoard(); - ctrlMgt(); - ctrlRw(); - ctrlStr(); - ctrlIfBoard(); - ctrlTcsBoard(); - ctrlObc(); - ctrlObcIfBoard(); - ctrlSBandTransceiver(); - ctrlPcduP60Board(); - ctrlPcduAcu(); - ctrlPcduPdu(); - ctrlPlPcduBoard(); - ctrlPlocMissionBoard(); - ctrlPlocProcessingBoard(); - ctrlDac(); + // ctrlAcsBoard(); + // ctrlMgt(); + // ctrlRw(); + // ctrlStr(); + // ctrlIfBoard(); + // ctrlTcsBoard(); + // ctrlObc(); + // ctrlObcIfBoard(); + // ctrlSBandTransceiver(); + // ctrlPcduP60Board(); + // ctrlPcduAcu(); + // ctrlPcduPdu(); + // ctrlPlPcduBoard(); + // ctrlPlocMissionBoard(); + // ctrlPlocProcessingBoard(); + // ctrlDac(); ctrlCameraBody(); - ctrlDro(); - ctrlX8(); - ctrlHpa(); - ctrlTx(); - ctrlMpa(); - ctrlScexBoard(); + // ctrlDro(); + // ctrlX8(); + // ctrlHpa(); + // ctrlTx(); + // ctrlMpa(); + // ctrlScexBoard(); + // heaterTransitionControl(); } - -void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - struct TempLimits& tempLimit) { - componentAboveCutOffLimit = false; - // Heater off - if (not heaterHandler.checkSwitchState(switchNr) and not thermalStates[thermalComponent].heating) { - if (sensorTemp < tempLimit.opLowerLimit) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; - thermalStates[thermalComponent].heating = true; - //TODO: EVENT - //TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in transition dann paar mal skippen mit transitionboolean; bool switchOnTransition und bool switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool clearen, falls drei erreicht heaterControlErrorCounter global zählen - } - // Heater on - } else if (heaterHandler.checkSwitchState(switchNr) and thermalStates[thermalComponent].heating) { - if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; //TODO: array mit struct enthält infos - thermalStates[thermalComponent].heating = false; - - } - } else if (redSwitchNrInUse) { - if (heaterHandler.checkSwitchState(redSwitchNr)) { - if (sensorTemp >= tempLimit.cutOffLimit) { - componentAboveCutOffLimit = true; - heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << redSwitchNr << " OFF" << std::endl; - } - } - } -} - -bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { - bool heaterAvailable = true; - - if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { - if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { - switchNr = redSwitchNr; - redSwitchNrInUse = true; - } else { - heaterAvailable = false; - triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); - } - } else { - redSwitchNrInUse = false; - } - return heaterAvailable; -} - -bool ThermalController::selectAndReadSensorTemp() { - for (unsigned i = 0; i < numSensors; i++) { - if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { - sensorTemp = sensors[i].second; - thermalStates[thermalComponent].errorCounter = 0; - return true; - } - } - - thermalStates[thermalComponent].errorCounter ++; - if(thermalComponent != rw and thermalComponent != acsBoard){ - if (thermalStates[thermalComponent].errorCounter <= 3){ - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); - } - }else{ - if (thermalStates[thermalComponent].errorCounter <= 8){ - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); - } - } - - return false; -} - void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits& tempLimit) { @@ -1458,12 +1387,116 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, } resetSensorsArray(); } +bool ThermalController::selectAndReadSensorTemp() { + for (unsigned i = 0; i < numSensors; i++) { + if (sensors[i].first and sensors[i].second != INVALID_TEMPERATURE) { + sensorTemp = sensors[i].second; + thermalStates[thermalComponent].errorCounter = 0; + return true; + } + } + thermalStates[thermalComponent].errorCounter++; + if (thermalComponent != rw and thermalComponent != acsBoard) { + if (thermalStates[thermalComponent].errorCounter <= 3) { + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + } + } else { + if (thermalStates[thermalComponent].errorCounter <= 8) { + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + } + } + + return false; +} +bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { + bool heaterAvailable = true; + + if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { + if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { + switchNr = redSwitchNr; + redSwitchNrInUse = true; + } else { + heaterAvailable = false; + triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + } + } else { + redSwitchNrInUse = false; + } + return heaterAvailable; +} +void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + struct TempLimits& tempLimit) { + componentAboveCutOffLimit = false; + // if Heater off + if (not heaterStates[switchNr].switchOnTransition and + not heaterStates[switchNr].switchOffTransition) { + if (not heaterHandler.checkSwitchState(switchNr) and + not thermalStates[thermalComponent].heating) { + if (sensorTemp < tempLimit.opLowerLimit) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); + heaterStates[switchNr].switchOnTransition = true; + sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON" + << std::endl; + thermalStates[thermalComponent].heating = true; + // TODO: EVENT; aber heaterHandler erstellt schon event + // TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in + // transition dann paar mal skippen; bool switchOnTransition und bool + // switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool + // clearen, falls drei erreicht heaterControlErrorCounter global zählen + } + + // if Heater on + } else if (heaterHandler.checkSwitchState(switchNr)) { + if (thermalStates[thermalComponent].heating) { + if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF" + << std::endl; + heaterStates[switchNr].switchOffTransition = true; + thermalStates[thermalComponent].heating = false; + } + } else { + if (sensorTemp >= tempLimit.cutOffLimit) { + componentAboveCutOffLimit = true; + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " + << thermalComponent << " OFF" << std::endl; + heaterStates[switchNr].switchOffTransition = true; + if (heaterHandler.checkSwitchState(redSwitchNr)) { + heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater " + << thermalComponent << " OFF" << std::endl; + heaterStates[redSwitchNr].switchOffTransition = true; + } + } + } + } + } +} void ThermalController::resetSensorsArray() { - // TODO: müssen auch andere Variablen resettet werden? senstemp? for (auto& validValuePair : sensors) { validValuePair.first = false; validValuePair.second = INVALID_TEMPERATURE; } thermalComponent = NONE; } +void ThermalController::heaterTransitionControl() { + for (unsigned i = 0; i < 7; i++) { + if (heaterStates[i].switchOffTransition) { + if (heaterStates[i].heaterSwitchOffControlErrorCounter > 3) { + heaterStates[i].switchOffTransition = false; + heaterStates[i].heaterSwitchOffControlErrorCounter = 0; + } + heaterStates[i].heaterSwitchOffControlErrorCounter++; + } + + if (heaterStates[i].switchOnTransition) { + if (heaterStates[i].heaterSwitchOnControlErrorCounter > 3) { + heaterStates[i].switchOnTransition = false; + heaterStates[i].heaterSwitchOnControlErrorCounter = 0; + } + heaterStates[i].heaterSwitchOnControlErrorCounter++; + } + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 590565c5..d23c8366 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -36,14 +36,21 @@ struct TempLimits { float nopUpperLimit; }; -struct ThermalState { +struct ThermalState { uint8_t errorCounter; bool heating; - uint32_t heaterStartTime; + uint32_t heaterStartTime; }; -enum ThermalComponents: uint8_t { - //TODO: Großbuchstaben +struct HeaterState { + bool switchOnTransition; + bool switchOffTransition; + uint8_t heaterSwitchOnControlErrorCounter; + uint8_t heaterSwitchOffControlErrorCounter; +}; + +enum ThermalComponents : uint8_t { + // TODO: Großbuchstaben NONE = 0, acsBoard = 1, mgt = 2, @@ -189,8 +196,8 @@ class ThermalController : public ExtendedControllerBase { ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; - std::array thermalStates {}; - + std::array thermalStates{}; + std::array heaterStates{}; // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); @@ -246,6 +253,7 @@ class ThermalController : public ExtendedControllerBase { void ctrlTx(); void ctrlMpa(); void ctrlScexBoard(); + void heaterTransitionControl(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index e099e91f..0993e233 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -434,8 +434,7 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie * // Prepare transfer int fileDescriptor = 0; std::string device = comIf->getSpiDev(); - UnixFileGuard fileHelper(device, - fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + UnixFileGuard fileHelper(device, fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); if (fileHelper.getOpenResult() != returnvalue::OK) { return SpiComIF::OPENING_FILE_FAILED; } diff --git a/mission/devices/ImtqHandler.cpp b/mission/devices/ImtqHandler.cpp index 18c002c4..aa935ce5 100644 --- a/mission/devices/ImtqHandler.cpp +++ b/mission/devices/ImtqHandler.cpp @@ -256,7 +256,7 @@ ReturnValue_t ImtqHandler::scanForReply(const uint8_t* start, size_t remainingSi ReturnValue_t ImtqHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t result; ReturnValue_t status = returnvalue::OK; - if(getMode() != MODE_NORMAL) { + if (getMode() != MODE_NORMAL) { // Ignore replies during transitions. return returnvalue::OK; } diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index 779e9aa8..32dba7fe 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -21,7 +21,7 @@ ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) { break; } count++; - if(count == 500) { + if (count == 500) { sif::error << "CfdpTmFunnel: Possible message storm detected" << std::endl; break; } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index e239afc9..974cdca0 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -21,7 +21,7 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { break; } count++; - if(count == 500) { + if (count == 500) { sif::error << "PusTmFunnel: Possible message storm detected" << std::endl; break; } diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 64c7b006..6a24cc09 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -50,7 +50,7 @@ ReturnValue_t VirtualChannel::performOperation() { } count++; - if(count == 500) { + if (count == 500) { sif::error << "VirtualChannel: Possible message storm detected" << std::endl; break; } -- 2.43.0 From 63275df3f03dd288c041c340b804ace1c843c7b3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 24 Feb 2023 13:39:23 +0100 Subject: [PATCH 07/51] formal changes --- mission/controller/ThermalController.cpp | 54 ++++++++++++------------ mission/controller/ThermalController.h | 46 ++++++++++---------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index de6b0023..3170b0b3 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -955,7 +955,7 @@ void ThermalController::ctrlAcsBoard() { heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; // A side - thermalComponent = acsBoard; + thermalComponent = ACS_BOARD; sensors[0].first = deviceTemperatures.gyro0SideA.isValid(); sensors[0].second = deviceTemperatures.gyro0SideA.value; sensors[1].first = deviceTemperatures.mgm0SideA.isValid(); @@ -999,7 +999,7 @@ void ThermalController::ctrlAcsBoard() { } void ThermalController::ctrlMgt() { - thermalComponent = mgt; + thermalComponent = MGT; PoolReadGuard pg(&imtqThermalSet); auto heaterReq = static_cast(imtqThermalSet.heaterRequest.value); @@ -1019,7 +1019,7 @@ void ThermalController::ctrlMgt() { void ThermalController::ctrlRw() { // TODO: better solution? // RW1 - thermalComponent = rw; + thermalComponent = RW; sensors[0].first = sensorTemperatures.sensor_rw1.isValid(); sensors[0].second = sensorTemperatures.sensor_rw1.value; sensors[1].first = deviceTemperatures.rw1.isValid(); @@ -1032,7 +1032,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW2 - thermalComponent = rw; + thermalComponent = RW; sensors[0].first = deviceTemperatures.rw2.isValid(); sensors[0].second = deviceTemperatures.rw2.value; sensors[1].first = deviceTemperatures.rw3.isValid(); @@ -1045,7 +1045,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW3 - thermalComponent = rw; + thermalComponent = RW; sensors[0].first = deviceTemperatures.rw3.isValid(); sensors[0].second = deviceTemperatures.rw3.value; sensors[1].first = deviceTemperatures.rw4.isValid(); @@ -1058,7 +1058,7 @@ void ThermalController::ctrlRw() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); // RW4 - thermalComponent = rw; + thermalComponent = RW; sensors[0].first = deviceTemperatures.rw4.isValid(); sensors[0].second = deviceTemperatures.rw4.value; sensors[1].first = deviceTemperatures.rw1.isValid(); @@ -1072,7 +1072,7 @@ void ThermalController::ctrlRw() { } void ThermalController::ctrlStr() { - thermalComponent = str; + thermalComponent = STR; sensors[0].first = sensorTemperatures.sensor_startracker.isValid(); sensors[0].second = sensorTemperatures.sensor_startracker.value; sensors[1].first = deviceTemperatures.startracker.isValid(); @@ -1084,7 +1084,7 @@ void ThermalController::ctrlStr() { } void ThermalController::ctrlIfBoard() { - thermalComponent = ifBoard; + thermalComponent = IF_BOARD; sensors[0].first = sensorTemperatures.tmp1075IfBrd.isValid(); sensors[0].second = sensorTemperatures.tmp1075IfBrd.value; sensors[1].first = sensorTemperatures.sensor_magnettorquer.isValid(); @@ -1096,7 +1096,7 @@ void ThermalController::ctrlIfBoard() { } void ThermalController::ctrlTcsBoard() { - thermalComponent = tcsBoard; + thermalComponent = TCS_BOARD; sensors[0].first = sensorTemperatures.sensor_tcs_board.isValid(); sensors[0].second = sensorTemperatures.sensor_tcs_board.value; sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); @@ -1108,7 +1108,7 @@ void ThermalController::ctrlTcsBoard() { } void ThermalController::ctrlObc() { - thermalComponent = obc; + thermalComponent = OBC; sensors[0].first = deviceTemperatures.q7s.isValid(); sensors[0].second = deviceTemperatures.q7s.value; sensors[1].first = sensorTemperatures.tmp1075Tcs1.isValid(); @@ -1123,7 +1123,7 @@ void ThermalController::ctrlObc() { } void ThermalController::ctrlObcIfBoard() { - thermalComponent = obcIfBoard; + thermalComponent = OBCIF_BOARD; sensors[0].first = deviceTemperatures.q7s.isValid(); sensors[0].second = deviceTemperatures.q7s.value; sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); @@ -1135,7 +1135,7 @@ void ThermalController::ctrlObcIfBoard() { } void ThermalController::ctrlSBandTransceiver() { - thermalComponent = sBandTransceiver; + thermalComponent = SBAND_TRANSCEIVER; sensors[0].first = deviceTemperatures.syrlinksPowerAmplifier.isValid(); sensors[0].second = deviceTemperatures.syrlinksPowerAmplifier.value; sensors[1].first = deviceTemperatures.syrlinksBasebandBoard.isValid(); @@ -1150,7 +1150,7 @@ void ThermalController::ctrlSBandTransceiver() { } } void ThermalController::ctrlPcduP60Board() { - thermalComponent = pcduP60Board; + thermalComponent = PCDUP60_BOARD; sensors[0].first = deviceTemperatures.temp1P60dock.isValid(); sensors[0].second = deviceTemperatures.temp1P60dock.value; sensors[1].first = deviceTemperatures.temp2P60dock.isValid(); @@ -1160,7 +1160,7 @@ void ThermalController::ctrlPcduP60Board() { } void ThermalController::ctrlPcduAcu() { - thermalComponent = pcduAcu; + thermalComponent = PCDUACU; heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; @@ -1187,7 +1187,7 @@ void ThermalController::ctrlPcduAcu() { } void ThermalController::ctrlPcduPdu() { - thermalComponent = pcduPdu; + thermalComponent = PCDUPDU; sensors[0].first = deviceTemperatures.pdu1.isValid(); sensors[0].second = deviceTemperatures.pdu1.value; sensors[1].first = deviceTemperatures.pdu2.isValid(); @@ -1199,7 +1199,7 @@ void ThermalController::ctrlPcduPdu() { } void ThermalController::ctrlPlPcduBoard() { - thermalComponent = plPcduBoard; + thermalComponent = PLPCDU_BOARD; sensors[0].first = sensorTemperatures.tmp1075PlPcdu0.isValid(); sensors[0].second = sensorTemperatures.tmp1075PlPcdu0.value; sensors[1].first = sensorTemperatures.tmp1075PlPcdu1.isValid(); @@ -1216,7 +1216,7 @@ void ThermalController::ctrlPlPcduBoard() { } void ThermalController::ctrlPlocMissionBoard() { - thermalComponent = plocMissionBoard; + thermalComponent = PLOCMISSION_BOARD; sensors[0].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); sensors[0].second = sensorTemperatures.sensor_ploc_heatspreader.value; sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); @@ -1232,7 +1232,7 @@ void ThermalController::ctrlPlocMissionBoard() { } void ThermalController::ctrlPlocProcessingBoard() { - thermalComponent = plocProcessingBoard; + thermalComponent = PLOCPROCESSING_BOARD; sensors[0].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); sensors[0].second = sensorTemperatures.sensor_ploc_missionboard.value; sensors[1].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); @@ -1245,7 +1245,7 @@ void ThermalController::ctrlPlocProcessingBoard() { } void ThermalController::ctrlDac() { - thermalComponent = dac; + thermalComponent = DAC; sensors[0].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); sensors[0].second = sensorTemperatures.sensor_dac_heatspreader.value; sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); @@ -1257,7 +1257,7 @@ void ThermalController::ctrlDac() { } void ThermalController::ctrlCameraBody() { - thermalComponent = camera; + thermalComponent = CAMERA; sensors[0].first = sensorTemperatures.sensor_4k_camera.isValid(); sensors[0].second = sensorTemperatures.sensor_4k_camera.value; sensors[1].first = sensorTemperatures.sensor_dro.isValid(); @@ -1269,7 +1269,7 @@ void ThermalController::ctrlCameraBody() { } void ThermalController::ctrlDro() { - thermalComponent = dro; + thermalComponent = DRO; sensors[0].first = sensorTemperatures.sensor_dro.isValid(); sensors[0].second = sensorTemperatures.sensor_dro.value; sensors[1].first = sensorTemperatures.sensor_4k_camera.isValid(); @@ -1281,7 +1281,7 @@ void ThermalController::ctrlDro() { } void ThermalController::ctrlX8() { - thermalComponent = x8; + thermalComponent = X8; sensors[0].first = sensorTemperatures.sensor_x8.isValid(); sensors[0].second = sensorTemperatures.sensor_x8.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); @@ -1293,7 +1293,7 @@ void ThermalController::ctrlX8() { } void ThermalController::ctrlTx() { - thermalComponent = tx; + thermalComponent = TX; sensors[0].first = sensorTemperatures.sensor_tx_modul.isValid(); sensors[0].second = sensorTemperatures.sensor_tx_modul.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); @@ -1305,7 +1305,7 @@ void ThermalController::ctrlTx() { } void ThermalController::ctrlMpa() { - thermalComponent = mpa; + thermalComponent = MPA; sensors[0].first = sensorTemperatures.sensor_mpa.isValid(); sensors[0].second = sensorTemperatures.sensor_mpa.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); @@ -1317,7 +1317,7 @@ void ThermalController::ctrlMpa() { } void ThermalController::ctrlHpa() { - thermalComponent = hpa; + thermalComponent = HPA; sensors[0].first = sensorTemperatures.sensor_hpa.isValid(); sensors[0].second = sensorTemperatures.sensor_hpa.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); @@ -1332,7 +1332,7 @@ void ThermalController::ctrlHpa() { } void ThermalController::ctrlScexBoard() { - thermalComponent = scexBoard; + thermalComponent = SCEX_BOARD; sensors[0].first = sensorTemperatures.sensor_scex.isValid(); sensors[0].second = sensorTemperatures.sensor_scex.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); @@ -1397,7 +1397,7 @@ bool ThermalController::selectAndReadSensorTemp() { } thermalStates[thermalComponent].errorCounter++; - if (thermalComponent != rw and thermalComponent != acsBoard) { + if (thermalComponent != RW and thermalComponent != ACS_BOARD) { if (thermalStates[thermalComponent].errorCounter <= 3) { triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index d23c8366..bca1c7fc 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -52,29 +52,29 @@ struct HeaterState { enum ThermalComponents : uint8_t { // TODO: Großbuchstaben NONE = 0, - acsBoard = 1, - mgt = 2, - rw = 3, - str = 4, - ifBoard = 5, - tcsBoard = 6, - obc = 7, - obcIfBoard = 8, - sBandTransceiver = 9, - pcduP60Board = 10, - pcduAcu = 11, - pcduPdu = 12, - plPcduBoard = 13, - plocMissionBoard = 14, - plocProcessingBoard = 15, - dac = 16, - camera = 17, - dro = 18, - x8 = 19, - hpa = 20, - tx = 21, - mpa = 22, - scexBoard = 23, + ACS_BOARD = 1, + MGT = 2, + RW = 3, + STR = 4, + IF_BOARD = 5, + TCS_BOARD = 6, + OBC = 7, + OBCIF_BOARD = 8, + SBAND_TRANSCEIVER = 9, + PCDUP60_BOARD = 10, + PCDUACU = 11, + PCDUPDU = 12, + PLPCDU_BOARD = 13, + PLOCMISSION_BOARD = 14, + PLOCPROCESSING_BOARD = 15, + DAC = 16, + CAMERA = 17, + DRO = 18, + X8 = 19, + HPA = 20, + TX = 21, + MPA = 22, + SCEX_BOARD = 23, NUM_ENTRIES }; -- 2.43.0 From 37b540fd4838d6585f3a0aa0bf1998c640476e1c Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 5 Mar 2023 13:05:32 +0100 Subject: [PATCH 08/51] switch Transition --- mission/controller/ThermalController.cpp | 39 +++++++++--------------- mission/controller/ThermalController.h | 7 ++--- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 22414caa..a9b1ee56 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1385,6 +1385,7 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, } } } + heaterTransitionControl(); resetSensorsArray(); } bool ThermalController::selectAndReadSensorTemp() { @@ -1429,21 +1430,17 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; // if Heater off - if (not heaterStates[switchNr].switchOnTransition and - not heaterStates[switchNr].switchOffTransition) { - if (not heaterHandler.checkSwitchState(switchNr) and - not thermalStates[thermalComponent].heating) { + if (not heaterStates[switchNr].switchTransition) { + if (not heaterHandler.checkSwitchState(switchNr)) { if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); - heaterStates[switchNr].switchOnTransition = true; sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON" << std::endl; + heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; // TODO: EVENT; aber heaterHandler erstellt schon event - // TODO: merken wenn an oder ausgeschaltet und erst nach drei zyklen wieder checken? wenn in - // transition dann paar mal skippen; bool switchOnTransition und bool - // switchOffTasnition, counter 3 zyklen dabei checken ob tansition erfolgreich, bool - // clearen, falls drei erreicht heaterControlErrorCounter global zählen + }else{ + thermalStates[thermalComponent].heating = false; } // if Heater on @@ -1453,7 +1450,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF" << std::endl; - heaterStates[switchNr].switchOffTransition = true; + heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = false; } } else { @@ -1462,12 +1459,12 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " << thermalComponent << " OFF" << std::endl; - heaterStates[switchNr].switchOffTransition = true; + heaterStates[switchNr].switchTransition = true; if (heaterHandler.checkSwitchState(redSwitchNr)) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater " << thermalComponent << " OFF" << std::endl; - heaterStates[redSwitchNr].switchOffTransition = true; + heaterStates[redSwitchNr].switchTransition = true; } } } @@ -1483,20 +1480,12 @@ void ThermalController::resetSensorsArray() { } void ThermalController::heaterTransitionControl() { for (unsigned i = 0; i < 7; i++) { - if (heaterStates[i].switchOffTransition) { - if (heaterStates[i].heaterSwitchOffControlErrorCounter > 3) { - heaterStates[i].switchOffTransition = false; - heaterStates[i].heaterSwitchOffControlErrorCounter = 0; + if (heaterStates[i].switchTransition) { + if (heaterStates[i].heaterSwitchControlErrorCounter > 3) { + heaterStates[i].switchTransition = false; + heaterStates[i].heaterSwitchControlErrorCounter = 0; } - heaterStates[i].heaterSwitchOffControlErrorCounter++; - } - - if (heaterStates[i].switchOnTransition) { - if (heaterStates[i].heaterSwitchOnControlErrorCounter > 3) { - heaterStates[i].switchOnTransition = false; - heaterStates[i].heaterSwitchOnControlErrorCounter = 0; - } - heaterStates[i].heaterSwitchOnControlErrorCounter++; + heaterStates[i].heaterSwitchControlErrorCounter++; } } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index bca1c7fc..2ddc519e 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -43,14 +43,11 @@ struct ThermalState { }; struct HeaterState { - bool switchOnTransition; - bool switchOffTransition; - uint8_t heaterSwitchOnControlErrorCounter; - uint8_t heaterSwitchOffControlErrorCounter; + bool switchTransition; + uint8_t heaterSwitchControlErrorCounter; }; enum ThermalComponents : uint8_t { - // TODO: Großbuchstaben NONE = 0, ACS_BOARD = 1, MGT = 2, -- 2.43.0 From 718d067b40829d37a84c77f944d2534f2898154e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 5 Mar 2023 13:27:42 +0100 Subject: [PATCH 09/51] small --- dummies/TemperatureSensorInserter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index e734b770..9d97836e 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -32,8 +32,11 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { tempsWereInitialized = true; } + //TDOD: -hpa mpa gleichzeitig + if (cycles == 10) { - max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(-100, true); + max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-100, true); + max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(-100, true); } /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); -- 2.43.0 From 7a6262468770a2ba16cfaa1a64e0fd20d4ffdd47 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 8 Mar 2023 15:56:05 +0100 Subject: [PATCH 10/51] changes --- dummies/TemperatureSensorInserter.cpp | 17 +++++++++++++++-- mission/controller/ThermalController.cpp | 6 +++--- mission/controller/ThermalController.h | 8 ++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 9d97836e..609c7b1b 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -32,12 +32,25 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { tempsWereInitialized = true; } - //TDOD: -hpa mpa gleichzeitig - if (cycles == 10) { max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-100, true); max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(-100, true); + } + + if (cycles == 35){ + max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(0, true); + max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(0, true); + max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(-100, true); + + + } + if (cycles == 60){ + max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-100, true); + max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(0, true); + + } + /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 1ef24e9d..3d69f7d8 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1360,12 +1360,12 @@ void ThermalController::performThermalModuleCtrl() { // ctrlPlocMissionBoard(); // ctrlPlocProcessingBoard(); // ctrlDac(); - ctrlCameraBody(); + ctrlCameraBody(); // ctrlDro(); // ctrlX8(); - // ctrlHpa(); + ctrlHpa(); // ctrlTx(); - // ctrlMpa(); + ctrlMpa(); // ctrlScexBoard(); // heaterTransitionControl(); } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index fbae8c55..cfcaf96f 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -183,10 +183,10 @@ class ThermalController : public ExtendedControllerBase { TempLimits dacLimits = TempLimits(-65.0, -40.0, 113.0, 118.0, 150.0); TempLimits cameraLimits = TempLimits(-40.0, -30.0, 60.0, 65.0, 85.0); TempLimits droLimits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0); - TempLimits x8Limits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0); - TempLimits hpaLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0); - TempLimits txLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0); - TempLimits mpaLimits = TempLimits(-40.0, -30.0, -75.0, 80.0, 90.0); + TempLimits x8Limits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0); + TempLimits hpaLimits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0); + TempLimits txLimits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0); + TempLimits mpaLimits = TempLimits(-40.0, -30.0, 75.0, 80.0, 90.0); TempLimits scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0); double sensorTemp = INVALID_TEMPERATURE; -- 2.43.0 From 131c508caecd3c718355682550fb9d3b5bef2330 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 9 Mar 2023 09:37:10 +0100 Subject: [PATCH 11/51] position heaterTransitionControl() --- dummies/TemperatureSensorInserter.cpp | 9 ++-- mission/controller/ThermalController.cpp | 54 ++++++++++++------------ 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 609c7b1b..3d268953 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -22,6 +22,7 @@ ReturnValue_t TemperatureSensorInserter::initialize() { } ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { + // TODO: deviceSensors if (not tempsWereInitialized) { for (auto& rtdDummy : max31865DummyMap) { rtdDummy.second->setTemperature(10, true); @@ -35,20 +36,16 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { if (cycles == 10) { max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-100, true); max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(-100, true); - } - if (cycles == 35){ + if (cycles == 35) { max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(0, true); max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(0, true); max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(-100, true); - - } - if (cycles == 60){ + if (cycles == 60) { max31865DummyMap[objects::RTD_9_IC12_HPA]->setTemperature(-100, true); max31865DummyMap[objects::RTD_11_IC14_MPA]->setTemperature(0, true); - } /* diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 3d69f7d8..fe104fa3 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1168,7 +1168,7 @@ void ThermalController::ctrlPcduAcu() { bool sensorTempAvailable = true; if (deviceTemperatures.acu.value[0] != - INVALID_TEMPERATURE) { // TODO: war invalid aber Wert 0 stat 999 + INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[1]; @@ -1344,30 +1344,30 @@ void ThermalController::ctrlScexBoard() { } void ThermalController::performThermalModuleCtrl() { - // ctrlAcsBoard(); - // ctrlMgt(); - // ctrlRw(); - // ctrlStr(); - // ctrlIfBoard(); - // ctrlTcsBoard(); - // ctrlObc(); - // ctrlObcIfBoard(); - // ctrlSBandTransceiver(); - // ctrlPcduP60Board(); - // ctrlPcduAcu(); - // ctrlPcduPdu(); - // ctrlPlPcduBoard(); - // ctrlPlocMissionBoard(); - // ctrlPlocProcessingBoard(); - // ctrlDac(); - ctrlCameraBody(); - // ctrlDro(); - // ctrlX8(); - ctrlHpa(); - // ctrlTx(); - ctrlMpa(); - // ctrlScexBoard(); - // heaterTransitionControl(); + ctrlAcsBoard(); + ctrlMgt(); + ctrlRw(); + ctrlStr(); + ctrlIfBoard(); + ctrlTcsBoard(); + ctrlObc(); + ctrlObcIfBoard(); + // ctrlSBandTransceiver(); + ctrlPcduP60Board(); + // ctrlPcduAcu(); + ctrlPcduPdu(); + ctrlPlPcduBoard(); + ctrlPlocMissionBoard(); + ctrlPlocProcessingBoard(); + ctrlDac(); + ctrlCameraBody(); + ctrlDro(); + ctrlX8(); + ctrlHpa(); + ctrlTx(); + ctrlMpa(); + ctrlScexBoard(); + heaterTransitionControl(); } void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, @@ -1385,7 +1385,6 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, } } } - heaterTransitionControl(); resetSensorsArray(); } bool ThermalController::selectAndReadSensorTemp() { @@ -1439,7 +1438,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; // TODO: EVENT; aber heaterHandler erstellt schon event - }else{ + } else { thermalStates[thermalComponent].heating = false; } @@ -1479,6 +1478,7 @@ void ThermalController::resetSensorsArray() { thermalComponent = NONE; } void ThermalController::heaterTransitionControl() { + // TODO: Test for (unsigned i = 0; i < 7; i++) { if (heaterStates[i].switchTransition) { if (heaterStates[i].heaterSwitchControlErrorCounter > 3) { -- 2.43.0 From c63b13fc40eaaab80280d3556ce326bc8956b8b3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 9 Mar 2023 16:53:48 +0100 Subject: [PATCH 12/51] overheating --- mission/controller/ThermalController.cpp | 58 +++++++++++++++++++++++- mission/controller/ThermalController.h | 1 + 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index fe104fa3..e9bd3ad1 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -14,6 +14,7 @@ #include #include #include +#include ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), @@ -1081,6 +1082,9 @@ void ThermalController::ctrlStr() { sensors[2].second = sensorTemperatures.sensor_dro.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::STAR_TRACKER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlIfBoard() { @@ -1146,8 +1150,9 @@ void ThermalController::ctrlSBandTransceiver() { ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); if (componentAboveCutOffLimit) { - triggerEvent(SYRLINKS_OVERHEATING); + triggerEvent(SYRLINKS_OVERHEATING); //TODO: TEMP mitgeben } + } void ThermalController::ctrlPcduP60Board() { thermalComponent = PCDUP60_BOARD; @@ -1184,6 +1189,9 @@ void ThermalController::ctrlPcduAcu() { ctrlHeater(switchNr, redSwitchNr, pcduAcuLimits); } } + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlPcduPdu() { @@ -1196,6 +1204,9 @@ void ThermalController::ctrlPcduPdu() { sensors[2].second = sensorTemperatures.tmp1075Tcs0.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlPlPcduBoard() { @@ -1229,6 +1240,9 @@ void ThermalController::ctrlPlocMissionBoard() { if (componentAboveCutOffLimit) { triggerEvent(PLOC_OVERHEATING); } + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLOC_MPSOC_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlPlocProcessingBoard() { @@ -1242,6 +1256,9 @@ void ThermalController::ctrlPlocProcessingBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocProcessingBoardLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLOC_MPSOC_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlDac() { @@ -1254,6 +1271,9 @@ void ThermalController::ctrlDac() { sensors[2].second = sensorTemperatures.sensor_ploc_heatspreader.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, dacLimits); + if (componentAboveOpUpperLimit){ + //EventManagerIF::triggerEvent(objects::, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlCameraBody() { @@ -1266,6 +1286,9 @@ void ThermalController::ctrlCameraBody() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits); +// if (componentAboveOpUpperLimit){ +// EventManagerIF::triggerEvent(objects::, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); +// } } void ThermalController::ctrlDro() { @@ -1278,6 +1301,9 @@ void ThermalController::ctrlDro() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlX8() { @@ -1290,6 +1316,9 @@ void ThermalController::ctrlX8() { sensors[2].second = sensorTemperatures.sensor_tx_modul.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlTx() { @@ -1302,6 +1331,9 @@ void ThermalController::ctrlTx() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlMpa() { @@ -1314,6 +1346,9 @@ void ThermalController::ctrlMpa() { sensors[2].second = sensorTemperatures.sensor_tx_modul.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlHpa() { @@ -1329,6 +1364,9 @@ void ThermalController::ctrlHpa() { if (componentAboveCutOffLimit) { triggerEvent(HPA_OVERHEATING); } + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::ctrlScexBoard() { @@ -1341,6 +1379,9 @@ void ThermalController::ctrlScexBoard() { sensors[2].second = sensorTemperatures.sensor_hpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); + if (componentAboveOpUpperLimit){ + EventManagerIF::triggerEvent(objects::SCEX, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + } } void ThermalController::performThermalModuleCtrl() { @@ -1381,7 +1422,7 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden? if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; // TODO: printouts löschen } } } @@ -1428,6 +1469,7 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; + componentAboveOpUpperLimit = false; // if Heater off if (not heaterStates[switchNr].switchTransition) { if (not heaterHandler.checkSwitchState(switchNr)) { @@ -1453,6 +1495,18 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers thermalStates[thermalComponent].heating = false; } } else { + // TODO: if >= opLimit -> Event; nicht für syrlinks + if (sensorTemp >= tempLimit.opUpperLimit) { + componentAboveOpUpperLimit = true; + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " + << 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.cutOffLimit) { componentAboveCutOffLimit = true; heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index cfcaf96f..7adaa2d3 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -193,6 +193,7 @@ class ThermalController : public ExtendedControllerBase { ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; bool componentAboveCutOffLimit = false; + bool componentAboveOpUpperLimit = false; std::array thermalStates{}; std::array heaterStates{}; -- 2.43.0 From 5793d73ff6b8a78ab2039234152cc0cefe747cb3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 13 Mar 2023 12:53:40 +0100 Subject: [PATCH 13/51] printouts --- mission/controller/ThermalController.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index e9bd3ad1..fdb6999a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1150,7 +1150,7 @@ void ThermalController::ctrlSBandTransceiver() { ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); if (componentAboveCutOffLimit) { - triggerEvent(SYRLINKS_OVERHEATING); //TODO: TEMP mitgeben + triggerEvent(SYRLINKS_OVERHEATING, static_cast(sensorTemp)); //TODO: TEMP mitgeben } } @@ -1422,7 +1422,7 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden? if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; // TODO: printouts löschen + sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(switchNr) << " OFF" << std::endl; // TODO: printouts löschen } } } @@ -1475,7 +1475,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers if (not heaterHandler.checkSwitchState(switchNr)) { if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); - sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " ON" + sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) << " ON" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; @@ -1489,7 +1489,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers if (thermalStates[thermalComponent].heating) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater " << thermalComponent << " OFF" + sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = false; @@ -1500,7 +1500,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers componentAboveOpUpperLimit = true; heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " - << thermalComponent << " OFF" << std::endl; + << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; if (heaterHandler.checkSwitchState(redSwitchNr)) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); -- 2.43.0 From a0d655278138eb51b7437e4016f30383e8d38333 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 13 Mar 2023 13:27:36 +0100 Subject: [PATCH 14/51] . --- mission/controller/ThermalController.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index fdb6999a..7703b8ab 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1150,6 +1150,9 @@ void ThermalController::ctrlSBandTransceiver() { ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); if (componentAboveCutOffLimit) { + float sensorTempAsFloat = sensorTemp; + + SerializeIF::serialize() triggerEvent(SYRLINKS_OVERHEATING, static_cast(sensorTemp)); //TODO: TEMP mitgeben } @@ -1190,7 +1193,7 @@ void ThermalController::ctrlPcduAcu() { } } if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); } } @@ -1205,7 +1208,9 @@ void ThermalController::ctrlPcduPdu() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits); if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); + EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); + }else if(componentAboveOpUpperLimit){ //TODO: NOp bool + EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); } } -- 2.43.0 From bf2d97bd60e32ba34ec230d203dd1c404a92d560 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 15:59:19 +0100 Subject: [PATCH 15/51] continue thermal controller overheating --- .idea/cmake.xml | 1 + bsp_q7s/core/CoreController.cpp | 22 +- mission/controller/ThermalController.cpp | 194 ++++++++++-------- mission/controller/ThermalController.h | 25 ++- mission/controller/acs/ActuatorCmd.cpp | 2 +- ...lControllerDefinitions.h => tcsCtrlDefs.h} | 26 ++- mission/system/objects/CamSwitcher.cpp | 5 + mission/system/objects/CamSwitcher.h | 1 + mission/system/objects/EiveSystem.cpp | 3 +- thirdparty/lwgps | 2 +- tmtc | 2 +- 11 files changed, 166 insertions(+), 117 deletions(-) rename mission/controller/controllerdefinitions/{ThermalControllerDefinitions.h => tcsCtrlDefs.h} (88%) diff --git a/.idea/cmake.xml b/.idea/cmake.xml index 3be3a2b0..f890b357 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -10,6 +10,7 @@ + \ No newline at end of file diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 702264ab..085d27de 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -32,8 +32,13 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP; xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY; CoreController::CoreController(object_id_t objectId) - : ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), cmdRepliesSizes(128), - opDivider5(5), opDivider10(10), hkSet(this) { + : ExtendedControllerBase(objectId, 5), + cmdExecutor(4096), + cmdReplyBuf(4096, true), + cmdRepliesSizes(128), + opDivider5(5), + opDivider10(10), + hkSet(this) { cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes); try { sdcMan = SdCardManager::instance(); @@ -102,14 +107,14 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); - if(shellCmdIsExecuting) { + if (shellCmdIsExecuting) { bool replyReceived = false; // TODO: We could read the data in the ring buffer and send it as an action data reply. - if(cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { + if (cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { actionHelper.finish(true, successRecipient, EXECUTE_SHELL_CMD); shellCmdIsExecuting = false; cmdReplyBuf.clear(); - while(not cmdRepliesSizes.empty()) { + while (not cmdRepliesSizes.empty()) { cmdRepliesSizes.pop(); } successRecipient = MessageQueueIF::NO_QUEUE; @@ -316,14 +321,15 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ // Warning: This function will never return, because it reboots the system return actionReboot(data, size); } - case(EXECUTE_SHELL_CMD): { + case (EXECUTE_SHELL_CMD): { std::string cmd = std::string(cmd, size); - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or shellCmdIsExecuting) { + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or + shellCmdIsExecuting) { return HasActionsIF::IS_BUSY; } cmdExecutor.load(cmd, false, false); ReturnValue_t result = cmdExecutor.execute(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } shellCmdIsExecuting = true; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 7703b8ab..0c8f9c3d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,6 +1,7 @@ #include "ThermalController.h" #include +#include #include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), @@ -65,8 +65,12 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater } ReturnValue_t ThermalController::initialize() { - auto result = ExtendedControllerBase::initialize(); - return result; + auto* camSwitcher = ObjectManager::instance()->get(objects::CAM_SWITCHER); + if (camSwitcher == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + camId = camSwitcher->getCommandQueue(); + return ExtendedControllerBase::initialize(); } ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { @@ -992,7 +996,8 @@ void ThermalController::ctrlAcsBoard() { if (chooseHeater(switchNr, redSwitchNr)) { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(thermalComponent) + << " OFF" << std::endl; } } } @@ -1082,9 +1087,7 @@ void ThermalController::ctrlStr() { sensors[2].second = sensorTemperatures.sensor_dro.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::STAR_TRACKER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::STAR_TRACKER, strTooHotFlag); } void ThermalController::ctrlIfBoard() { @@ -1121,8 +1124,11 @@ void ThermalController::ctrlObc() { sensors[2].second = sensorTemperatures.tmp1075Tcs0.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcLimits); - if (componentAboveCutOffLimit) { - triggerEvent(OBC_OVERHEATING); + if (componentAboveUpperLimit and not obcTooHotFlag) { + triggerEvent(tcsCtrl::OBC_OVERHEATING); + obcTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + obcTooHotFlag = false; } } @@ -1136,6 +1142,12 @@ void ThermalController::ctrlObcIfBoard() { sensors[2].second = sensorTemperatures.tmp1075Tcs1.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcIfBoardLimits); + if (componentAboveUpperLimit and not obcTooHotFlag) { + triggerEvent(tcsCtrl::OBC_OVERHEATING); + obcTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + obcTooHotFlag = false; + } } void ThermalController::ctrlSBandTransceiver() { @@ -1149,13 +1161,12 @@ void ThermalController::ctrlSBandTransceiver() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); - if (componentAboveCutOffLimit) { - float sensorTempAsFloat = sensorTemp; - - SerializeIF::serialize() - triggerEvent(SYRLINKS_OVERHEATING, static_cast(sensorTemp)); //TODO: TEMP mitgeben + if (componentAboveUpperLimit and not syrlinksTooHotFlag) { + triggerEvent(tcsCtrl::SYRLINKS_OVERHEATING, tempFloatToU32()); + syrlinksTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + pcduSystemTooHotFlag = false; } - } void ThermalController::ctrlPcduP60Board() { thermalComponent = PCDUP60_BOARD; @@ -1165,6 +1176,12 @@ void ThermalController::ctrlPcduP60Board() { sensors[1].second = deviceTemperatures.temp2P60dock.value; numSensors = 2; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduP60BoardLimits); + if (componentAboveUpperLimit and not pcduSystemTooHotFlag) { + triggerEvent(tcsCtrl::PCDU_SYSTEM_OVERHEATING, tempFloatToU32()); + pcduSystemTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + pcduSystemTooHotFlag = false; + } } void ThermalController::ctrlPcduAcu() { @@ -1175,8 +1192,7 @@ void ThermalController::ctrlPcduAcu() { if (chooseHeater(switchNr, redSwitchNr)) { bool sensorTempAvailable = true; - if (deviceTemperatures.acu.value[0] != - INVALID_TEMPERATURE) { + if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[1]; @@ -1185,15 +1201,18 @@ void ThermalController::ctrlPcduAcu() { } else if (sensorTemperatures.sensor_acu.isValid()) { sensorTemp = sensorTemperatures.sensor_acu.value; } else { - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, thermalComponent); sensorTempAvailable = false; } if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, pcduAcuLimits); } } - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); + if (componentAboveUpperLimit and not pcduSystemTooHotFlag) { + triggerEvent(tcsCtrl::PCDU_SYSTEM_OVERHEATING, tempFloatToU32()); + pcduSystemTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + pcduSystemTooHotFlag = false; } } @@ -1207,10 +1226,11 @@ void ThermalController::ctrlPcduPdu() { sensors[2].second = sensorTemperatures.tmp1075Tcs0.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); - }else if(componentAboveOpUpperLimit){ //TODO: NOp bool - EventManagerIF::triggerEvent(objects::PCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_HIGH); + if (componentAboveUpperLimit and not pcduSystemTooHotFlag) { + triggerEvent(tcsCtrl::PCDU_SYSTEM_OVERHEATING, tempFloatToU32()); + pcduSystemTooHotFlag = true; + } else if (not componentAboveUpperLimit) { + pcduSystemTooHotFlag = false; } } @@ -1226,9 +1246,7 @@ void ThermalController::ctrlPlPcduBoard() { sensors[3].second = sensorTemperatures.sensor_plpcdu_heatspreader.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, plPcduBoardLimits); - if (componentAboveCutOffLimit) { - triggerEvent(PLPCDU_OVERHEATING); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlPlocMissionBoard() { @@ -1242,12 +1260,7 @@ void ThermalController::ctrlPlocMissionBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocMissionBoardLimits); - if (componentAboveCutOffLimit) { - triggerEvent(PLOC_OVERHEATING); - } - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLOC_MPSOC_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLOC_MPSOC_HANDLER, plocTooHotFlag); } void ThermalController::ctrlPlocProcessingBoard() { @@ -1261,9 +1274,7 @@ void ThermalController::ctrlPlocProcessingBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocProcessingBoardLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLOC_MPSOC_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLOC_MPSOC_HANDLER, plocTooHotFlag); } void ThermalController::ctrlDac() { @@ -1276,9 +1287,7 @@ void ThermalController::ctrlDac() { sensors[2].second = sensorTemperatures.sensor_ploc_heatspreader.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, dacLimits); - if (componentAboveOpUpperLimit){ - //EventManagerIF::triggerEvent(objects::, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlCameraBody() { @@ -1291,9 +1300,19 @@ void ThermalController::ctrlCameraBody() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits); -// if (componentAboveOpUpperLimit){ -// EventManagerIF::triggerEvent(objects::, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); -// } + if (componentAboveUpperLimit and not camTooHotOneShotFlag) { + triggerEvent(tcsCtrl::CAMERA_OVERHEATING, tempFloatToU32()); + CommandMessage msg; + HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HealthState::FAULTY); + ReturnValue_t result = commandQueue->sendMessage(camId, &msg); + if (result != returnvalue::OK) { + sif::error << "ThermalController::ctrlCameraBody(): Sending health message failed" + << std::endl; + } + camTooHotOneShotFlag = true; + } else if (not componentAboveUpperLimit) { + camTooHotOneShotFlag = false; + } } void ThermalController::ctrlDro() { @@ -1306,9 +1325,7 @@ void ThermalController::ctrlDro() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlX8() { @@ -1321,9 +1338,7 @@ void ThermalController::ctrlX8() { sensors[2].second = sensorTemperatures.sensor_tx_modul.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlTx() { @@ -1336,9 +1351,7 @@ void ThermalController::ctrlTx() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlMpa() { @@ -1351,9 +1364,7 @@ void ThermalController::ctrlMpa() { sensors[2].second = sensorTemperatures.sensor_tx_modul.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlHpa() { @@ -1366,12 +1377,7 @@ void ThermalController::ctrlHpa() { sensors[2].second = sensorTemperatures.sensor_mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, hpaLimits); - if (componentAboveCutOffLimit) { - triggerEvent(HPA_OVERHEATING); - } - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::PLPCDU_HANDLER, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); } void ThermalController::ctrlScexBoard() { @@ -1384,9 +1390,7 @@ void ThermalController::ctrlScexBoard() { sensors[2].second = sensorTemperatures.sensor_hpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); - if (componentAboveOpUpperLimit){ - EventManagerIF::triggerEvent(objects::SCEX, ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH); - } + tooHotHandler(objects::SCEX, scexTooHotFlag); } void ThermalController::performThermalModuleCtrl() { @@ -1427,7 +1431,8 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden? if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(switchNr) << " OFF" << std::endl; // TODO: printouts löschen + sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(switchNr) + << " OFF" << std::endl; // TODO: printouts löschen } } } @@ -1445,11 +1450,11 @@ bool ThermalController::selectAndReadSensorTemp() { thermalStates[thermalComponent].errorCounter++; if (thermalComponent != RW and thermalComponent != ACS_BOARD) { if (thermalStates[thermalComponent].errorCounter <= 3) { - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } } else { if (thermalStates[thermalComponent].errorCounter <= 8) { - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, thermalComponent); + triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, thermalComponent); } } @@ -1464,7 +1469,7 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch redSwitchNrInUse = true; } else { heaterAvailable = false; - triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + triggerEvent(tcsCtrl::NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); } } else { redSwitchNrInUse = false; @@ -1474,17 +1479,16 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; - componentAboveOpUpperLimit = false; + componentAboveUpperLimit = false; // if Heater off if (not heaterStates[switchNr].switchTransition) { if (not heaterHandler.checkSwitchState(switchNr)) { if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); - sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) << " ON" - << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) + << " ON" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; - // TODO: EVENT; aber heaterHandler erstellt schon event } else { thermalStates[thermalComponent].heating = false; } @@ -1494,36 +1498,34 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers if (thermalStates[thermalComponent].heating) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) << " OFF" - << std::endl; + sif::info << "ThermalController::ctrlHeater: Heater " + << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = false; } } else { - // TODO: if >= opLimit -> Event; nicht für syrlinks - if (sensorTemp >= tempLimit.opUpperLimit) { - componentAboveOpUpperLimit = true; + auto tempTooHighHandler = [&](const char* whatLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " - << static_cast(thermalComponent) << " OFF" << std::endl; + sif::info << "ThermalController::ctrlHeater: Reached " << whatLimit << ": Heater " + << static_cast(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) { componentAboveCutOffLimit = true; - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: Heater " - << thermalComponent << " OFF" << std::endl; - heaterStates[switchNr].switchTransition = true; - if (heaterHandler.checkSwitchState(redSwitchNr)) { - heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Reached CutOffLimit: RedundantHeater " - << thermalComponent << " OFF" << std::endl; - heaterStates[redSwitchNr].switchTransition = true; - } + tempTooHighHandler("CutOff-Limit"); } } } @@ -1548,3 +1550,19 @@ void ThermalController::heaterTransitionControl() { } } } +uint32_t ThermalController::tempFloatToU32() { + auto sensorTempAsFloat = static_cast(sensorTemp); + uint32_t tempRaw = 0; + size_t dummyLen = 0; + SerializeAdapter::serialize(&sensorTempAsFloat, reinterpret_cast(&tempRaw), &dummyLen, + sizeof(tempRaw), SerializeIF::Endianness::NETWORK); + return tempRaw; +} +void ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { + if (componentAboveUpperLimit and not oneShotFlag) { + EventManagerIF::triggerEvent(object, overHeatEventToTrigger, tempFloatToU32()); + oneShotFlag = true; + } else if (not componentAboveUpperLimit) { + oneShotFlag = false; + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 7adaa2d3..3da82c22 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,15 +97,6 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_CONTROLLER; - static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::MEDIUM); - static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(1, severity::MEDIUM); - static constexpr Event SYRLINKS_OVERHEATING = MAKE_EVENT(2, severity::HIGH); - static constexpr Event PLOC_OVERHEATING = MAKE_EVENT(3, severity::HIGH); - static constexpr Event OBC_OVERHEATING = MAKE_EVENT(4, severity::HIGH); - static constexpr Event HPA_OVERHEATING = MAKE_EVENT(5, severity::HIGH); - static constexpr Event PLPCDU_OVERHEATING = MAKE_EVENT(6, severity::HIGH); - static const uint32_t DELAY = 500; static const uint32_t TEMP_OFFSET = 5; @@ -192,8 +183,18 @@ class ThermalController : public ExtendedControllerBase { double sensorTemp = INVALID_TEMPERATURE; ThermalComponents thermalComponent = NONE; bool redSwitchNrInUse = false; + MessageQueueId_t camId = MessageQueueIF::NO_QUEUE; bool componentAboveCutOffLimit = false; - bool componentAboveOpUpperLimit = false; + bool componentAboveUpperLimit = false; + Event overHeatEventToTrigger; + bool eBandTooHotFlag = false; + bool camTooHotOneShotFlag = false; + bool scexTooHotFlag = false; + bool plocTooHotFlag = false; + bool pcduSystemTooHotFlag = false; + bool syrlinksTooHotFlag = false; + bool obcTooHotFlag = false; + bool strTooHotFlag = false; std::array thermalStates{}; std::array heaterStates{}; @@ -252,6 +253,8 @@ class ThermalController : public ExtendedControllerBase { void ctrlMpa(); void ctrlScexBoard(); void heaterTransitionControl(); + uint32_t tempFloatToU32(); + void tooHotHandler(object_id_t object, bool& oneShotFlag); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 457cacce..d2fe2d65 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -49,7 +49,7 @@ void ActuatorCmd::cmdSpeedToRws(int32_t speedRw0, int32_t speedRw1, int32_t spee } else if (rwCmdSpeed[i] < -maxRwSpeed) { rwCmdSpeed[i] = -maxRwSpeed; } - } + } } void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/tcsCtrlDefs.h similarity index 88% rename from mission/controller/controllerdefinitions/ThermalControllerDefinitions.h rename to mission/controller/controllerdefinitions/tcsCtrlDefs.h index e7c95218..aa1fb4a1 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/tcsCtrlDefs.h @@ -5,9 +5,19 @@ #include #include "devices/heaterSwitcherList.h" +#include "eive/eventSubsystemIds.h" namespace tcsCtrl { +static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_CONTROLLER; +static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::MEDIUM); +static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(1, severity::MEDIUM); +static constexpr Event SYRLINKS_OVERHEATING = MAKE_EVENT(2, severity::HIGH); +static constexpr Event PLOC_OVERHEATING = MAKE_EVENT(3, severity::HIGH); +static constexpr Event OBC_OVERHEATING = MAKE_EVENT(4, severity::HIGH); +static constexpr Event CAMERA_OVERHEATING = MAKE_EVENT(5, severity::HIGH); +static constexpr Event PCDU_SYSTEM_OVERHEATING = MAKE_EVENT(6, severity::HIGH); + enum SetId : uint32_t { SENSOR_TEMPERATURES = 0, DEVICE_TEMPERATURES = 1, @@ -93,9 +103,10 @@ static const uint8_t ENTRIES_SUS_TEMPERATURE_SET = 12; */ class SensorTemperatures : public StaticLocalDataSet { public: - SensorTemperatures(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {} + explicit SensorTemperatures(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {} - SensorTemperatures(object_id_t objectId) + explicit SensorTemperatures(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SENSOR_TEMPERATURES)) {} lp_var_t sensor_ploc_heatspreader = @@ -137,9 +148,10 @@ class SensorTemperatures : public StaticLocalDataSet { public: - DeviceTemperatures(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DEVICE_TEMPERATURES) {} + explicit DeviceTemperatures(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DEVICE_TEMPERATURES) {} - DeviceTemperatures(object_id_t objectId) + explicit DeviceTemperatures(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, DEVICE_TEMPERATURES)) {} lp_var_t q7s = lp_var_t(sid.objectId, PoolIds::TEMP_Q7S, this); @@ -178,9 +190,11 @@ class DeviceTemperatures : public StaticLocalDataSet { public: - SusTemperatures(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_TEMPERATURES) {} + explicit SusTemperatures(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, SUS_TEMPERATURES) {} - SusTemperatures(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_TEMPERATURES)) {} + explicit SusTemperatures(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, SUS_TEMPERATURES)) {} lp_var_t sus_0_n_loc_xfyfzm_pt_xf = lp_var_t(sid.objectId, PoolIds::SUS_0_N_LOC_XFYFZM_PT_XF, this); diff --git a/mission/system/objects/CamSwitcher.cpp b/mission/system/objects/CamSwitcher.cpp index b995e211..90a78945 100644 --- a/mission/system/objects/CamSwitcher.cpp +++ b/mission/system/objects/CamSwitcher.cpp @@ -3,3 +3,8 @@ CamSwitcher::CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, power::Switch_t pwrSwitch) : PowerSwitcherComponent(objectId, &pwrSwitcher, pwrSwitch) {} +void CamSwitcher::performFaultyOperation() { + if (not switcher.active() and switcher.getState() != PowerSwitcher::SWITCH_IS_OFF) { + switcher.turnOff(); + } +} diff --git a/mission/system/objects/CamSwitcher.h b/mission/system/objects/CamSwitcher.h index 672b884b..57f371ce 100644 --- a/mission/system/objects/CamSwitcher.h +++ b/mission/system/objects/CamSwitcher.h @@ -8,6 +8,7 @@ class CamSwitcher : public PowerSwitcherComponent { CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, power::Switch_t pwrSwitch); private: + void performFaultyOperation() override; }; #endif /* MISSION_SYSTEM_OBJECTS_CAMSWITCHER_H_ */ diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index bb2a229d..4b330a89 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -51,7 +51,7 @@ void EiveSystem::performChildOperation() { } ReturnValue_t EiveSystem::initialize() { - EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "AcsSubsystem::initialize: Invalid event manager" << std::endl; @@ -67,6 +67,7 @@ ReturnValue_t EiveSystem::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } + // TODO: manager->subscribeToEvent(eventQueue->getId(), ) return Subsystem::initialize(); } diff --git a/thirdparty/lwgps b/thirdparty/lwgps index 52999ddf..22d86566 160000 --- a/thirdparty/lwgps +++ b/thirdparty/lwgps @@ -1 +1 @@ -Subproject commit 52999ddfe5177493b96b55871961a8a97131596d +Subproject commit 22d865662eb7be6c9849275da9166f6b410f906a diff --git a/tmtc b/tmtc index a40c881b..d8367f7e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a40c881b9fc292fe598204280db38720a784b71f +Subproject commit d8367f7e62a47516d7772c129c18ee8f7b07703b -- 2.43.0 From 9d1d62aee0cd687934dda78c430e1a00576c9817 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 16:02:24 +0100 Subject: [PATCH 16/51] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9a8d775e..7208343b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a8d775eb1a8788ad844215bf2a42d9f707767c0 +Subproject commit 7208343b6d41d70c264918ef1ef0277d3663c8c1 -- 2.43.0 From 26a9dce0a0c271f6e8843774aef8025674c1c063 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 17:36:41 +0100 Subject: [PATCH 17/51] basic implementation for passive cooling --- dummies/AcuDummy.cpp | 3 +- dummies/SyrlinksDummy.cpp | 4 +- mission/controller/ThermalController.cpp | 83 ++++++++++++++----- mission/controller/ThermalController.h | 8 +- .../controllerdefinitions/tcsCtrlDefs.h | 1 - mission/system/objects/EiveSystem.cpp | 42 +++++++++- mission/system/objects/EiveSystem.h | 6 +- 7 files changed, 116 insertions(+), 31 deletions(-) diff --git a/dummies/AcuDummy.cpp b/dummies/AcuDummy.cpp index d6ba21d1..27f079e0 100644 --- a/dummies/AcuDummy.cpp +++ b/dummies/AcuDummy.cpp @@ -37,6 +37,7 @@ uint32_t AcuDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return ReturnValue_t AcuDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ACU::pool::ACU_TEMPERATURES, new PoolEntry(3)); + localDataPoolMap.emplace(ACU::pool::ACU_TEMPERATURES, + new PoolEntry({10.0, 10.0, 10.0}, true)); return returnvalue::OK; } diff --git a/dummies/SyrlinksDummy.cpp b/dummies/SyrlinksDummy.cpp index 49c1319f..72b0a761 100644 --- a/dummies/SyrlinksDummy.cpp +++ b/dummies/SyrlinksDummy.cpp @@ -40,7 +40,7 @@ uint32_t SyrlinksDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { r ReturnValue_t SyrlinksDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(syrlinks::TEMP_BASEBAND_BOARD, new PoolEntry({0})); - localDataPoolMap.emplace(syrlinks::TEMP_POWER_AMPLIFIER, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TEMP_BASEBAND_BOARD, new PoolEntry({10}, true)); + localDataPoolMap.emplace(syrlinks::TEMP_POWER_AMPLIFIER, new PoolEntry({10}, true)); return returnvalue::OK; } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 0c8f9c3d..8427acd6 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -972,7 +972,7 @@ void ThermalController::ctrlAcsBoard() { numSensors = 4; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { - ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); + checkLimitsAndCtrlHeater(switchNr, redSwitchNr, acsBoardLimits); } resetSensorsArray(); return; @@ -990,14 +990,14 @@ void ThermalController::ctrlAcsBoard() { numSensors = 4; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { - ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); + checkLimitsAndCtrlHeater(switchNr, redSwitchNr, acsBoardLimits); } } else { if (chooseHeater(switchNr, redSwitchNr)) { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(thermalComponent) - << " OFF" << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater" + << static_cast(thermalComponent) << " OFF" << std::endl; } } } @@ -1023,7 +1023,11 @@ void ThermalController::ctrlMgt() { } void ThermalController::ctrlRw() { - // TODO: better solution? + Event eventToTrigger = 0; + bool oneIsAboveLimit = false; + + std::array sensorTemps{}; + // RW1 thermalComponent = RW; sensors[0].first = sensorTemperatures.sensor_rw1.isValid(); @@ -1036,6 +1040,11 @@ void ThermalController::ctrlRw() { sensors[3].second = sensorTemperatures.sensor_dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + sensorTemps[0] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + eventToTrigger = overHeatEventToTrigger; + } // RW2 thermalComponent = RW; @@ -1049,6 +1058,13 @@ void ThermalController::ctrlRw() { sensors[3].second = sensorTemperatures.sensor_dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + sensorTemps[1] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { + eventToTrigger = overHeatEventToTrigger; + } + } // RW3 thermalComponent = RW; @@ -1062,6 +1078,13 @@ void ThermalController::ctrlRw() { sensors[3].second = sensorTemperatures.sensor_dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + sensorTemps[2] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { + eventToTrigger = overHeatEventToTrigger; + } + } // RW4 thermalComponent = RW; @@ -1075,6 +1098,23 @@ void ThermalController::ctrlRw() { sensors[3].second = sensorTemperatures.sensor_dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + sensorTemps[3] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { + eventToTrigger = overHeatEventToTrigger; + } + } + + if (oneIsAboveLimit and not rwTooHotFlag) { + EventManagerIF::triggerEvent(objects::RW1, eventToTrigger, sensorTemps[0]); + EventManagerIF::triggerEvent(objects::RW2, eventToTrigger, sensorTemps[1]); + EventManagerIF::triggerEvent(objects::RW3, eventToTrigger, sensorTemps[2]); + EventManagerIF::triggerEvent(objects::RW4, eventToTrigger, sensorTemps[3]); + rwTooHotFlag = true; + } else if (not oneIsAboveLimit) { + rwTooHotFlag = false; + } } void ThermalController::ctrlStr() { @@ -1100,6 +1140,7 @@ void ThermalController::ctrlIfBoard() { sensors[2].second = deviceTemperatures.mgm2SideB.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, ifBoardLimits); + // TODO: special event overheating + could go back to safe mode } void ThermalController::ctrlTcsBoard() { @@ -1112,6 +1153,7 @@ void ThermalController::ctrlTcsBoard() { sensors[2].second = sensorTemperatures.tmp1075Tcs1.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, tcsBoardLimits); + // TODO: special event overheating + could go back to safe mode } void ThermalController::ctrlObc() { @@ -1205,7 +1247,7 @@ void ThermalController::ctrlPcduAcu() { sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, pcduAcuLimits); + checkLimitsAndCtrlHeater(switchNr, redSwitchNr, pcduAcuLimits); } } if (componentAboveUpperLimit and not pcduSystemTooHotFlag) { @@ -1402,9 +1444,9 @@ void ThermalController::performThermalModuleCtrl() { ctrlTcsBoard(); ctrlObc(); ctrlObcIfBoard(); - // ctrlSBandTransceiver(); + ctrlSBandTransceiver(); ctrlPcduP60Board(); - // ctrlPcduAcu(); + ctrlPcduAcu(); ctrlPcduPdu(); ctrlPlPcduBoard(); ctrlPlocMissionBoard(); @@ -1424,15 +1466,16 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, TempLimits& tempLimit) { if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { - ctrlHeater(switchNr, redSwitchNr, tempLimit); + checkLimitsAndCtrlHeater(switchNr, redSwitchNr, tempLimit); } } else { if (chooseHeater(switchNr, redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden? if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << static_cast(switchNr) - << " OFF" << std::endl; // TODO: printouts löschen + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater" + << static_cast(thermalComponent) << " OFF" + << std::endl; // TODO: printouts löschen } } } @@ -1476,17 +1519,19 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } return heaterAvailable; } -void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - struct TempLimits& tempLimit) { +void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, + heater::Switchers redSwitchNr, + struct TempLimits& tempLimit) { componentAboveCutOffLimit = false; componentAboveUpperLimit = false; // if Heater off if (not heaterStates[switchNr].switchTransition) { if (not heaterHandler.checkSwitchState(switchNr)) { + // TODO: check NOP limit and maybe trigger fdir if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); - sif::info << "ThermalController::ctrlHeater: Heater " << static_cast(thermalComponent) - << " ON" << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " + << static_cast(thermalComponent) << " ON" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; } else { @@ -1498,7 +1543,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers if (thermalStates[thermalComponent].heating) { if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater " + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = false; @@ -1506,8 +1551,8 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers } else { auto tempTooHighHandler = [&](const char* whatLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Reached " << whatLimit << ": Heater " - << static_cast(thermalComponent) << " OFF" << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Reached " << whatLimit + << ": Heater " << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; if (heaterHandler.checkSwitchState(redSwitchNr)) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); @@ -1550,7 +1595,7 @@ void ThermalController::heaterTransitionControl() { } } } -uint32_t ThermalController::tempFloatToU32() { +uint32_t ThermalController::tempFloatToU32() const { auto sensorTempAsFloat = static_cast(sensorTemp); uint32_t tempRaw = 0; size_t dummyLen = 0; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 3da82c22..accfecbb 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -164,6 +164,8 @@ class ThermalController : public ExtendedControllerBase { TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 130.0); TempLimits obcLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0); TempLimits obcIfBoardLimits = TempLimits(-65.0, -40.0, 80.0, 85.0, 125.0); + // Limits to test commading to RX Only + // TempLimits sBandTransceiverLimits = TempLimits(-40.0, -25.0, 0.0, 0.0, 5.0); TempLimits sBandTransceiverLimits = TempLimits(-40.0, -25.0, 35.0, 40.0, 65.0); TempLimits pcduP60BoardLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0); TempLimits pcduAcuLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0); @@ -195,6 +197,7 @@ class ThermalController : public ExtendedControllerBase { bool syrlinksTooHotFlag = false; bool obcTooHotFlag = false; bool strTooHotFlag = false; + bool rwTooHotFlag = false; std::array thermalStates{}; std::array heaterStates{}; @@ -225,7 +228,8 @@ class ThermalController : public ExtendedControllerBase { void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits& tempLimit); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits& tempLimit); + void checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + TempLimits& tempLimit); bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); bool selectAndReadSensorTemp(); @@ -253,7 +257,7 @@ class ThermalController : public ExtendedControllerBase { void ctrlMpa(); void ctrlScexBoard(); void heaterTransitionControl(); - uint32_t tempFloatToU32(); + uint32_t tempFloatToU32() const; void tooHotHandler(object_id_t object, bool& oneShotFlag); }; diff --git a/mission/controller/controllerdefinitions/tcsCtrlDefs.h b/mission/controller/controllerdefinitions/tcsCtrlDefs.h index aa1fb4a1..6644199f 100644 --- a/mission/controller/controllerdefinitions/tcsCtrlDefs.h +++ b/mission/controller/controllerdefinitions/tcsCtrlDefs.h @@ -13,7 +13,6 @@ static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_CONTROLLER; static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::MEDIUM); static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(1, severity::MEDIUM); static constexpr Event SYRLINKS_OVERHEATING = MAKE_EVENT(2, severity::HIGH); -static constexpr Event PLOC_OVERHEATING = MAKE_EVENT(3, severity::HIGH); static constexpr Event OBC_OVERHEATING = MAKE_EVENT(4, severity::HIGH); static constexpr Event CAMERA_OVERHEATING = MAKE_EVENT(5, severity::HIGH); static constexpr Event PCDU_SYSTEM_OVERHEATING = MAKE_EVENT(6, severity::HIGH); diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index 4b330a89..f2c6fcff 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -4,11 +4,13 @@ #include #include #include +#include +#include EiveSystem::EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) : Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) { - auto mqArgs = MqArgs(getObjectId(), static_cast(this)); + auto mqArgs = MqArgs(SubsystemBase::getObjectId(), static_cast(this)); eventQueue = QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs); } @@ -67,16 +69,37 @@ ReturnValue_t EiveSystem::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - // TODO: manager->subscribeToEvent(eventQueue->getId(), ) + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::SYRLINKS_OVERHEATING)); + manager->subscribeToEvent(eventQueue->getId(), + event::getEventId(tcsCtrl::PCDU_SYSTEM_OVERHEATING)); + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::OBC_OVERHEATING)); + return Subsystem::initialize(); } void EiveSystem::handleEventMessages() { EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; - result = eventQueue->receiveMessage(&event)) { + for (ReturnValue_t status = eventQueue->receiveMessage(&event); status == returnvalue::OK; + status = eventQueue->receiveMessage(&event)) { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: + switch (event.getEvent()) { + case tcsCtrl::SYRLINKS_OVERHEATING: { + CommandMessage msg; + ModeMessage::setCmdModeMessage(msg, com::RX_ONLY, 0); + ReturnValue_t result = + commandQueue->sendMessage(childrenMap[objects::COM_SUBSYSTEM].commandQueue, &msg); + if (result != returnvalue::OK) { + sif::error << "EiveSystem: Commanding COM to RX_ONLY failed" << std::endl; + } + break; + } + case tcsCtrl::OBC_OVERHEATING: + case tcsCtrl::PCDU_SYSTEM_OVERHEATING: { + commandSelfToSafe(); + break; + } + } break; default: sif::debug << "AcsSubsystem::performChildOperation: Did not subscribe " @@ -86,3 +109,14 @@ void EiveSystem::handleEventMessages() { } } } +void EiveSystem::commandSelfToSafe() { + if (fallbackCommandCd.hasTimedOut()) { + CommandMessage msg; + ModeMessage::setCmdModeMessage(msg, acs::AcsMode::SAFE, 0); + ReturnValue_t result = commandQueue->sendMessage(commandQueue->getId(), &msg); + if (result != returnvalue::OK) { + sif::error << "EiveSystem: Commanding EIVE-System to SAFE failed" << std::endl; + } + fallbackCommandCd.resetTimer(); + } +} diff --git a/mission/system/objects/EiveSystem.h b/mission/system/objects/EiveSystem.h index 0d75b31a..ab586e42 100644 --- a/mission/system/objects/EiveSystem.h +++ b/mission/system/objects/EiveSystem.h @@ -8,12 +8,14 @@ class EiveSystem : public Subsystem { EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables); private: + MessageQueueIF* eventQueue = nullptr; + Countdown fallbackCommandCd = Countdown(30000); + ReturnValue_t initialize() override; void performChildOperation() override; void announceMode(bool recursive) override; void handleEventMessages(); - - MessageQueueIF* eventQueue = nullptr; + void commandSelfToSafe(); }; #endif /* MISSION_SYSTEM_EIVESYSTEM_H_ */ -- 2.43.0 From 8b1130202886520a1ec7d4bd469c6102cf9daa52 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 20:35:49 +0100 Subject: [PATCH 18/51] unittest works again --- mission/core/GenericFactory.cpp | 4 ++-- unittest/controller/testThermalController.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 8bf4eff6..3130c51e 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -112,8 +112,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } { - PoolManager::LocalPoolConfig poolCfg = {{600, 32}, {400, 64}, {400, 128}, {300, 512}, - {250, 1024}, {150, 2048}}; + PoolManager::LocalPoolConfig poolCfg = {{600, 32}, {400, 64}, {400, 128}, + {300, 512}, {250, 1024}, {150, 2048}}; *tmStore = new PoolManager(objects::TM_STORE, poolCfg); } diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 0772018e..d83980ee 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -19,7 +20,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { TemperatureSensorInserter::Tmp1075DummyMap map1; new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, map0, map1); auto dummyGpioIF = new DummyGpioIF(); - auto dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); + auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); + new CamSwitcher(objects::CAM_SWITCHER, *dummySwitcher, pcdu::Switches::PDU2_CH8_PAYLOAD_CAMERA); // TODO: Create dummy heater handler HeaterHandler* heaterHandler = nullptr; // new ThermalController(objects::THERMAL_CONTROLLER); -- 2.43.0 From 69525b6fd1d6f063255b17e4369e08a873a9ad88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 14:10:53 +0100 Subject: [PATCH 19/51] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index d0607824..43fd0b2f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d0607824ad551771e4e3ec1f1752f5f2f6a1a7a8 +Subproject commit 43fd0b2f59c3aeb2d3f4db10cfad56ee3709d68d -- 2.43.0 From d2736214190961e535aa4c1a6a32bc7e7e08712e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 14:36:18 +0100 Subject: [PATCH 20/51] some tweaks --- mission/controller/ThermalController.cpp | 15 ++++++++++----- mission/controller/ThermalController.h | 4 ++-- tmtc | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 8427acd6..e0630309 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1448,22 +1448,27 @@ void ThermalController::performThermalModuleCtrl() { ctrlPcduP60Board(); ctrlPcduAcu(); ctrlPcduPdu(); - ctrlPlPcduBoard(); + + // Payload components ctrlPlocMissionBoard(); ctrlPlocProcessingBoard(); - ctrlDac(); ctrlCameraBody(); + ctrlScexBoard(); + + // E-Band + ctrlPlPcduBoard(); + ctrlDac(); ctrlDro(); ctrlX8(); ctrlHpa(); ctrlTx(); ctrlMpa(); - ctrlScexBoard(); + heaterTransitionControl(); } void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, - TempLimits& tempLimit) { + const TempLimits& tempLimit) { if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { checkLimitsAndCtrlHeater(switchNr, redSwitchNr, tempLimit); @@ -1521,7 +1526,7 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - struct TempLimits& tempLimit) { + const TempLimits& tempLimit) { componentAboveCutOffLimit = false; componentAboveUpperLimit = false; // if Heater off diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index accfecbb..fc3c9e4b 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -227,9 +227,9 @@ class ThermalController : public ExtendedControllerBase { void copyDevices(); void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, - TempLimits& tempLimit); + const TempLimits& tempLimit); void checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - TempLimits& tempLimit); + const TempLimits& tempLimit); bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); bool selectAndReadSensorTemp(); diff --git a/tmtc b/tmtc index a54e5a8e..4f48c25b 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a54e5a8e143380131bcb66fd6ff8b8ad48390e05 +Subproject commit 4f48c25bf757b6c056072049fe5965da890b4f5b -- 2.43.0 From a92fa31cb5eb7ebae501f0b47c7673b7e28336c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 14:56:26 +0100 Subject: [PATCH 21/51] better variable names, tweaks for less init events --- dummies/GyroAdisDummy.cpp | 2 +- dummies/MgmLIS3MDLDummy.cpp | 2 +- dummies/StarTrackerDummy.cpp | 2 +- mission/controller/ThermalController.cpp | 337 +++++++++--------- mission/controller/ThermalController.h | 32 +- .../controllerdefinitions/tcsCtrlDefs.h | 21 +- 6 files changed, 203 insertions(+), 193 deletions(-) diff --git a/dummies/GyroAdisDummy.cpp b/dummies/GyroAdisDummy.cpp index c7c40a1a..9be4747c 100644 --- a/dummies/GyroAdisDummy.cpp +++ b/dummies/GyroAdisDummy.cpp @@ -46,7 +46,7 @@ ReturnValue_t GyroAdisDummy::initializeLocalDataPool(localpool::DataPool &localD localDataPoolMap.emplace(adis1650x::ACCELERATION_X, new PoolEntry({0.0})); localDataPoolMap.emplace(adis1650x::ACCELERATION_Y, new PoolEntry({0.0})); localDataPoolMap.emplace(adis1650x::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(adis1650x::TEMPERATURE, new PoolEntry({0.0})); + localDataPoolMap.emplace(adis1650x::TEMPERATURE, new PoolEntry({10.0}, true)); return returnvalue::OK; } diff --git a/dummies/MgmLIS3MDLDummy.cpp b/dummies/MgmLIS3MDLDummy.cpp index 0ce9a520..03b163fc 100644 --- a/dummies/MgmLIS3MDLDummy.cpp +++ b/dummies/MgmLIS3MDLDummy.cpp @@ -40,7 +40,7 @@ uint32_t MgmLIS3MDLDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { ReturnValue_t MgmLIS3MDLDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(mgmLis3::TEMPERATURE_CELCIUS, new PoolEntry({0.0})); + localDataPoolMap.emplace(mgmLis3::TEMPERATURE_CELCIUS, new PoolEntry({10.0}, true)); localDataPoolMap.emplace(mgmLis3::FIELD_STRENGTHS, new PoolEntry({1.02, 0.56, -0.78}, true)); return returnvalue::OK; diff --git a/dummies/StarTrackerDummy.cpp b/dummies/StarTrackerDummy.cpp index 71f0030c..2f12367c 100644 --- a/dummies/StarTrackerDummy.cpp +++ b/dummies/StarTrackerDummy.cpp @@ -40,7 +40,7 @@ uint32_t StarTrackerDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) ReturnValue_t StarTrackerDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(startracker::MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(startracker::MCU_TEMPERATURE, new PoolEntry({10.0}, true)); localDataPoolMap.emplace(startracker::TICKS_SOLUTION_SET, new PoolEntry({0})); localDataPoolMap.emplace(startracker::TIME_SOLUTION_SET, new PoolEntry({0})); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index e0630309..a30ac08f 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -16,6 +16,8 @@ #include #include +#define LOWER_SYRLINKS_UPPER_LIMITS 0 + ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), heaterHandler(heater), @@ -24,25 +26,26 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater deviceTemperatures(this), heaterInfo(this), imtqThermalSet(objects::IMTQ_HANDLER, ThermalStateCfg()), - max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER, - EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD, - EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set2(objects::RTD_2_IC5_4K_CAMERA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set3(objects::RTD_3_IC6_DAC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set4(objects::RTD_4_IC7_STARTRACKER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set5(objects::RTD_5_IC8_RW1_MX_MY, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set6(objects::RTD_6_IC9_DRO, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set7(objects::RTD_7_IC10_SCEX, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set8(objects::RTD_8_IC11_X8, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set9(objects::RTD_9_IC12_HPA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set10(objects::RTD_10_IC13_PL_TX, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set11(objects::RTD_11_IC14_MPA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set12(objects::RTD_12_IC15_ACU, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set13(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set14(objects::RTD_14_IC17_TCS_BOARD, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - max31865Set15(objects::RTD_15_IC18_IMTQ, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet1PlocHspd(objects::RTD_0_IC3_PLOC_HEATSPREADER, + EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet0PlocMissionBrd(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet2PlCam(objects::RTD_2_IC5_4K_CAMERA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet3DacHspd(objects::RTD_3_IC6_DAC_HEATSPREADER, + EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet4Str(objects::RTD_4_IC7_STARTRACKER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet5Rw1MxMy(objects::RTD_5_IC8_RW1_MX_MY, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet6Dro(objects::RTD_6_IC9_DRO, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet7Scex(objects::RTD_7_IC10_SCEX, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet8X8(objects::RTD_8_IC11_X8, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet9Hpa(objects::RTD_9_IC12_HPA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet10EbandTx(objects::RTD_10_IC13_PL_TX, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet11Mpa(objects::RTD_11_IC14_MPA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet31865Set12(objects::RTD_12_IC15_ACU, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet13PlPcduHspd(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet14TcsBrd(objects::RTD_14_IC17_TCS_BOARD, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), + maxSet15Imtq(objects::RTD_15_IC18_IMTQ, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), tmp1075SetTcs0(objects::TMP1075_HANDLER_TCS_0), tmp1075SetTcs1(objects::TMP1075_HANDLER_TCS_1), tmp1075SetPlPcdu0(objects::TMP1075_HANDLER_PLPCDU_0), @@ -62,6 +65,12 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet10(objects::SUS_10_N_LOC_XMYBZF_PT_ZF), susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) { resetSensorsArray(); + +#if LOWER_SYRLINKS_UPPER_LIMITS == 1 + sBandTransceiverLimits.cutOffLimit = 0; + sBandTransceiverLimits.opUpperLimit = 0; + sBandTransceiverLimits.nopUpperLimit = 0; +#endif } ReturnValue_t ThermalController::initialize() { @@ -241,101 +250,99 @@ ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode void ThermalController::copySensors() { { - PoolReadGuard pg0(&max31865Set0, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg0(&maxSet1PlocHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg0.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_ploc_heatspreader.value = max31865Set0.temperatureCelcius.value; - sensorTemperatures.sensor_ploc_heatspreader.setValid( - max31865Set0.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_ploc_heatspreader.isValid()) { - sensorTemperatures.sensor_ploc_heatspreader.value = INVALID_TEMPERATURE; + sensorTemperatures.plocHeatspreader.value = maxSet1PlocHspd.temperatureCelcius.value; + sensorTemperatures.plocHeatspreader.setValid(maxSet1PlocHspd.temperatureCelcius.isValid()); + if (not sensorTemperatures.plocHeatspreader.isValid()) { + sensorTemperatures.plocHeatspreader.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg1(&max31865Set1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg1(&maxSet0PlocMissionBrd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg1.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_ploc_missionboard.value = max31865Set1.temperatureCelcius.value; - sensorTemperatures.sensor_ploc_missionboard.setValid( - max31865Set1.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_ploc_missionboard.isValid()) { - sensorTemperatures.sensor_ploc_missionboard.value = INVALID_TEMPERATURE; + sensorTemperatures.plocMissionboard.value = maxSet0PlocMissionBrd.temperatureCelcius.value; + sensorTemperatures.plocMissionboard.setValid( + maxSet0PlocMissionBrd.temperatureCelcius.isValid()); + if (not sensorTemperatures.plocMissionboard.isValid()) { + sensorTemperatures.plocMissionboard.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg2(&max31865Set2, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg2(&maxSet2PlCam, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg2.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_4k_camera.value = max31865Set2.temperatureCelcius.value; - sensorTemperatures.sensor_4k_camera.setValid(max31865Set2.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_4k_camera.isValid()) { - sensorTemperatures.sensor_4k_camera.value = INVALID_TEMPERATURE; + sensorTemperatures.payload4kCamera.value = maxSet2PlCam.temperatureCelcius.value; + sensorTemperatures.payload4kCamera.setValid(maxSet2PlCam.temperatureCelcius.isValid()); + if (not sensorTemperatures.payload4kCamera.isValid()) { + sensorTemperatures.payload4kCamera.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg3(&max31865Set3, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg3(&maxSet3DacHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg3.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_dac_heatspreader.value = max31865Set3.temperatureCelcius.value; - sensorTemperatures.sensor_dac_heatspreader.setValid( - max31865Set3.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_dac_heatspreader.isValid()) { - sensorTemperatures.sensor_dac_heatspreader.value = INVALID_TEMPERATURE; + sensorTemperatures.dacHeatspreader.value = maxSet3DacHspd.temperatureCelcius.value; + sensorTemperatures.dacHeatspreader.setValid(maxSet3DacHspd.temperatureCelcius.isValid()); + if (not sensorTemperatures.dacHeatspreader.isValid()) { + sensorTemperatures.dacHeatspreader.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg4(&max31865Set4, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg4(&maxSet4Str, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg4.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_startracker.value = max31865Set4.temperatureCelcius.value; - sensorTemperatures.sensor_startracker.setValid(max31865Set4.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_startracker.isValid()) { - sensorTemperatures.sensor_startracker.value = INVALID_TEMPERATURE; + sensorTemperatures.startracker.value = maxSet4Str.temperatureCelcius.value; + sensorTemperatures.startracker.setValid(maxSet4Str.temperatureCelcius.isValid()); + if (not sensorTemperatures.startracker.isValid()) { + sensorTemperatures.startracker.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg5(&max31865Set5, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg5(&maxSet5Rw1MxMy, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg5.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_rw1.value = max31865Set5.temperatureCelcius.value; - sensorTemperatures.sensor_rw1.setValid(max31865Set5.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_rw1.isValid()) { - sensorTemperatures.sensor_rw1.value = INVALID_TEMPERATURE; + sensorTemperatures.rw1.value = maxSet5Rw1MxMy.temperatureCelcius.value; + sensorTemperatures.rw1.setValid(maxSet5Rw1MxMy.temperatureCelcius.isValid()); + if (not sensorTemperatures.rw1.isValid()) { + sensorTemperatures.rw1.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg6(&max31865Set6, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg6(&maxSet6Dro, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg6.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_dro.value = max31865Set6.temperatureCelcius.value; - sensorTemperatures.sensor_dro.setValid(max31865Set6.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_dro.isValid()) { - sensorTemperatures.sensor_dro.value = INVALID_TEMPERATURE; + sensorTemperatures.dro.value = maxSet6Dro.temperatureCelcius.value; + sensorTemperatures.dro.setValid(maxSet6Dro.temperatureCelcius.isValid()); + if (not sensorTemperatures.dro.isValid()) { + sensorTemperatures.dro.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg7(&max31865Set7, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg7(&maxSet7Scex, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg7.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_scex.value = max31865Set7.temperatureCelcius.value; - sensorTemperatures.sensor_scex.setValid(max31865Set7.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_scex.isValid()) { - sensorTemperatures.sensor_scex.value = INVALID_TEMPERATURE; + sensorTemperatures.scex.value = maxSet7Scex.temperatureCelcius.value; + sensorTemperatures.scex.setValid(maxSet7Scex.temperatureCelcius.isValid()); + if (not sensorTemperatures.scex.isValid()) { + sensorTemperatures.scex.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg8(&max31865Set8, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg8(&maxSet8X8, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg8.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_x8.value = max31865Set8.temperatureCelcius.value; - sensorTemperatures.sensor_x8.setValid(max31865Set8.temperatureCelcius.isValid()); + sensorTemperatures.sensor_x8.value = maxSet8X8.temperatureCelcius.value; + sensorTemperatures.sensor_x8.setValid(maxSet8X8.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_x8.isValid()) { sensorTemperatures.sensor_x8.value = INVALID_TEMPERATURE; } @@ -343,10 +350,10 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg9(&max31865Set9, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg9(&maxSet9Hpa, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg9.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_hpa.value = max31865Set9.temperatureCelcius.value; - sensorTemperatures.sensor_hpa.setValid(max31865Set9.temperatureCelcius.isValid()); + sensorTemperatures.sensor_hpa.value = maxSet9Hpa.temperatureCelcius.value; + sensorTemperatures.sensor_hpa.setValid(maxSet9Hpa.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_hpa.isValid()) { sensorTemperatures.sensor_hpa.value = INVALID_TEMPERATURE; } @@ -354,32 +361,32 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg10(&max31865Set10, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg10(&maxSet10EbandTx, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg10.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_tx_modul.value = max31865Set10.temperatureCelcius.value; - sensorTemperatures.sensor_tx_modul.setValid(max31865Set10.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_tx_modul.isValid()) { - sensorTemperatures.sensor_tx_modul.value = INVALID_TEMPERATURE; + sensorTemperatures.eBandTx.value = maxSet10EbandTx.temperatureCelcius.value; + sensorTemperatures.eBandTx.setValid(maxSet10EbandTx.temperatureCelcius.isValid()); + if (not sensorTemperatures.eBandTx.isValid()) { + sensorTemperatures.eBandTx.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg11(&max31865Set11, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg11(&maxSet11Mpa, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg11.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_mpa.value = max31865Set11.temperatureCelcius.value; - sensorTemperatures.sensor_mpa.setValid(max31865Set11.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_mpa.isValid()) { - sensorTemperatures.sensor_mpa.value = INVALID_TEMPERATURE; + sensorTemperatures.mpa.value = maxSet11Mpa.temperatureCelcius.value; + sensorTemperatures.mpa.setValid(maxSet11Mpa.temperatureCelcius.isValid()); + if (not sensorTemperatures.mpa.isValid()) { + sensorTemperatures.mpa.value = INVALID_TEMPERATURE; } } } { - PoolReadGuard pg12(&max31865Set12, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg12(&maxSet31865Set12, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg12.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_acu.value = max31865Set12.temperatureCelcius.value; - sensorTemperatures.sensor_acu.setValid(max31865Set12.temperatureCelcius.isValid()); + sensorTemperatures.sensor_acu.value = maxSet31865Set12.temperatureCelcius.value; + sensorTemperatures.sensor_acu.setValid(maxSet31865Set12.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_acu.isValid()) { sensorTemperatures.sensor_acu.value = INVALID_TEMPERATURE; } @@ -387,11 +394,12 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg13(&max31865Set13, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg13(&maxSet13PlPcduHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg13.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_plpcdu_heatspreader.value = max31865Set13.temperatureCelcius.value; + sensorTemperatures.sensor_plpcdu_heatspreader.value = + maxSet13PlPcduHspd.temperatureCelcius.value; sensorTemperatures.sensor_plpcdu_heatspreader.setValid( - max31865Set13.temperatureCelcius.isValid()); + maxSet13PlPcduHspd.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { sensorTemperatures.sensor_plpcdu_heatspreader.value = INVALID_TEMPERATURE; } @@ -399,10 +407,10 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg14(&max31865Set14, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg14(&maxSet14TcsBrd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg14.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_tcs_board.value = max31865Set14.temperatureCelcius.value; - sensorTemperatures.sensor_tcs_board.setValid(max31865Set14.temperatureCelcius.isValid()); + sensorTemperatures.sensor_tcs_board.value = maxSet14TcsBrd.temperatureCelcius.value; + sensorTemperatures.sensor_tcs_board.setValid(maxSet14TcsBrd.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_tcs_board.isValid()) { sensorTemperatures.sensor_tcs_board.value = INVALID_TEMPERATURE; } @@ -410,10 +418,10 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg15(&max31865Set15, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg15(&maxSet15Imtq, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg15.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_magnettorquer.value = max31865Set15.temperatureCelcius.value; - sensorTemperatures.sensor_magnettorquer.setValid(max31865Set15.temperatureCelcius.isValid()); + sensorTemperatures.sensor_magnettorquer.value = maxSet15Imtq.temperatureCelcius.value; + sensorTemperatures.sensor_magnettorquer.setValid(maxSet15Imtq.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_magnettorquer.isValid()) { sensorTemperatures.sensor_magnettorquer.value = INVALID_TEMPERATURE; } @@ -963,13 +971,15 @@ void ThermalController::ctrlAcsBoard() { thermalComponent = ACS_BOARD; sensors[0].first = deviceTemperatures.gyro0SideA.isValid(); sensors[0].second = deviceTemperatures.gyro0SideA.value; - sensors[1].first = deviceTemperatures.mgm0SideA.isValid(); - sensors[1].second = deviceTemperatures.mgm0SideA.value; - sensors[2].first = deviceTemperatures.gyro1SideA.isValid(); - sensors[2].second = deviceTemperatures.gyro1SideA.value; - sensors[3].first = sensorTemperatures.sensor_tcs_board.isValid(); - sensors[3].second = sensorTemperatures.sensor_tcs_board.value; - numSensors = 4; + sensors[1].first = deviceTemperatures.gyro2SideB.isValid(); + sensors[1].second = deviceTemperatures.gyro2SideB.value; + sensors[2].first = deviceTemperatures.mgm0SideA.isValid(); + sensors[2].second = deviceTemperatures.mgm0SideA.value; + sensors[3].first = deviceTemperatures.mgm2SideB.isValid(); + sensors[3].second = deviceTemperatures.mgm2SideB.value; + sensors[4].first = sensorTemperatures.sensor_tcs_board.isValid(); + sensors[5].second = sensorTemperatures.sensor_tcs_board.value; + numSensors = 5; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { checkLimitsAndCtrlHeater(switchNr, redSwitchNr, acsBoardLimits); @@ -1030,14 +1040,14 @@ void ThermalController::ctrlRw() { // RW1 thermalComponent = RW; - sensors[0].first = sensorTemperatures.sensor_rw1.isValid(); - sensors[0].second = sensorTemperatures.sensor_rw1.value; + sensors[0].first = sensorTemperatures.rw1.isValid(); + sensors[0].second = sensorTemperatures.rw1.value; sensors[1].first = deviceTemperatures.rw1.isValid(); sensors[1].second = deviceTemperatures.rw1.value; sensors[2].first = deviceTemperatures.rw4.isValid(); sensors[2].second = deviceTemperatures.rw4.value; - sensors[3].first = sensorTemperatures.sensor_dro.isValid(); - sensors[3].second = sensorTemperatures.sensor_dro.value; + sensors[3].first = sensorTemperatures.dro.isValid(); + sensors[3].second = sensorTemperatures.dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); sensorTemps[0] = tempFloatToU32(); @@ -1052,10 +1062,10 @@ void ThermalController::ctrlRw() { sensors[0].second = deviceTemperatures.rw2.value; sensors[1].first = deviceTemperatures.rw3.isValid(); sensors[1].second = deviceTemperatures.rw3.value; - sensors[2].first = sensorTemperatures.sensor_rw1.isValid(); - sensors[2].second = sensorTemperatures.sensor_rw1.value; - sensors[3].first = sensorTemperatures.sensor_dro.isValid(); - sensors[3].second = sensorTemperatures.sensor_dro.value; + sensors[2].first = sensorTemperatures.rw1.isValid(); + sensors[2].second = sensorTemperatures.rw1.value; + sensors[3].first = sensorTemperatures.dro.isValid(); + sensors[3].second = sensorTemperatures.dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); sensorTemps[1] = tempFloatToU32(); @@ -1072,10 +1082,10 @@ void ThermalController::ctrlRw() { sensors[0].second = deviceTemperatures.rw3.value; sensors[1].first = deviceTemperatures.rw4.isValid(); sensors[1].second = deviceTemperatures.rw4.value; - sensors[2].first = sensorTemperatures.sensor_rw1.isValid(); - sensors[2].second = sensorTemperatures.sensor_rw1.value; - sensors[3].first = sensorTemperatures.sensor_dro.isValid(); - sensors[3].second = sensorTemperatures.sensor_dro.value; + sensors[2].first = sensorTemperatures.rw1.isValid(); + sensors[2].second = sensorTemperatures.rw1.value; + sensors[3].first = sensorTemperatures.dro.isValid(); + sensors[3].second = sensorTemperatures.dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); sensorTemps[2] = tempFloatToU32(); @@ -1092,10 +1102,10 @@ void ThermalController::ctrlRw() { sensors[0].second = deviceTemperatures.rw4.value; sensors[1].first = deviceTemperatures.rw1.isValid(); sensors[1].second = deviceTemperatures.rw1.value; - sensors[2].first = sensorTemperatures.sensor_rw1.isValid(); - sensors[2].second = sensorTemperatures.sensor_rw1.value; - sensors[3].first = sensorTemperatures.sensor_dro.isValid(); - sensors[3].second = sensorTemperatures.sensor_dro.value; + sensors[2].first = sensorTemperatures.rw1.isValid(); + sensors[2].second = sensorTemperatures.rw1.value; + sensors[3].first = sensorTemperatures.dro.isValid(); + sensors[3].second = sensorTemperatures.dro.value; numSensors = 4; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); sensorTemps[3] = tempFloatToU32(); @@ -1119,12 +1129,12 @@ void ThermalController::ctrlRw() { void ThermalController::ctrlStr() { thermalComponent = STR; - sensors[0].first = sensorTemperatures.sensor_startracker.isValid(); - sensors[0].second = sensorTemperatures.sensor_startracker.value; + sensors[0].first = sensorTemperatures.startracker.isValid(); + sensors[0].second = sensorTemperatures.startracker.value; sensors[1].first = deviceTemperatures.startracker.isValid(); sensors[1].second = deviceTemperatures.startracker.value; - sensors[2].first = sensorTemperatures.sensor_dro.isValid(); - sensors[2].second = sensorTemperatures.sensor_dro.value; + sensors[2].first = sensorTemperatures.dro.isValid(); + sensors[2].second = sensorTemperatures.dro.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits); tooHotHandler(objects::STAR_TRACKER, strTooHotFlag); @@ -1198,8 +1208,8 @@ void ThermalController::ctrlSBandTransceiver() { sensors[0].second = deviceTemperatures.syrlinksPowerAmplifier.value; sensors[1].first = deviceTemperatures.syrlinksBasebandBoard.isValid(); sensors[1].second = deviceTemperatures.syrlinksBasebandBoard.value; - sensors[2].first = sensorTemperatures.sensor_4k_camera.isValid(); - sensors[2].second = sensorTemperatures.sensor_4k_camera.value; + 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); @@ -1293,12 +1303,12 @@ void ThermalController::ctrlPlPcduBoard() { void ThermalController::ctrlPlocMissionBoard() { thermalComponent = PLOCMISSION_BOARD; - sensors[0].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); - sensors[0].second = sensorTemperatures.sensor_ploc_heatspreader.value; - sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); - sensors[1].second = sensorTemperatures.sensor_ploc_missionboard.value; - sensors[2].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); - sensors[2].second = sensorTemperatures.sensor_dac_heatspreader.value; + sensors[0].first = sensorTemperatures.plocHeatspreader.isValid(); + sensors[0].second = sensorTemperatures.plocHeatspreader.value; + sensors[1].first = sensorTemperatures.plocMissionboard.isValid(); + sensors[1].second = sensorTemperatures.plocMissionboard.value; + 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, plocMissionBoardLimits); @@ -1307,12 +1317,12 @@ void ThermalController::ctrlPlocMissionBoard() { void ThermalController::ctrlPlocProcessingBoard() { thermalComponent = PLOCPROCESSING_BOARD; - sensors[0].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); - sensors[0].second = sensorTemperatures.sensor_ploc_missionboard.value; - sensors[1].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); - sensors[1].second = sensorTemperatures.sensor_ploc_heatspreader.value; - sensors[2].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); - sensors[2].second = sensorTemperatures.sensor_dac_heatspreader.value; + sensors[0].first = sensorTemperatures.plocMissionboard.isValid(); + sensors[0].second = sensorTemperatures.plocMissionboard.value; + sensors[1].first = sensorTemperatures.plocHeatspreader.isValid(); + sensors[1].second = sensorTemperatures.plocHeatspreader.value; + 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, plocProcessingBoardLimits); @@ -1321,12 +1331,12 @@ void ThermalController::ctrlPlocProcessingBoard() { void ThermalController::ctrlDac() { thermalComponent = DAC; - sensors[0].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); - sensors[0].second = sensorTemperatures.sensor_dac_heatspreader.value; - sensors[1].first = sensorTemperatures.sensor_ploc_missionboard.isValid(); - sensors[1].second = sensorTemperatures.sensor_ploc_missionboard.value; - sensors[2].first = sensorTemperatures.sensor_ploc_heatspreader.isValid(); - sensors[2].second = sensorTemperatures.sensor_ploc_heatspreader.value; + sensors[0].first = sensorTemperatures.dacHeatspreader.isValid(); + sensors[0].second = sensorTemperatures.dacHeatspreader.value; + sensors[1].first = sensorTemperatures.plocMissionboard.isValid(); + sensors[1].second = sensorTemperatures.plocMissionboard.value; + 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); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1334,12 +1344,12 @@ void ThermalController::ctrlDac() { void ThermalController::ctrlCameraBody() { thermalComponent = CAMERA; - sensors[0].first = sensorTemperatures.sensor_4k_camera.isValid(); - sensors[0].second = sensorTemperatures.sensor_4k_camera.value; - sensors[1].first = sensorTemperatures.sensor_dro.isValid(); - sensors[1].second = sensorTemperatures.sensor_dro.value; - sensors[2].first = sensorTemperatures.sensor_mpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_mpa.value; + sensors[0].first = sensorTemperatures.payload4kCamera.isValid(); + sensors[0].second = sensorTemperatures.payload4kCamera.value; + sensors[1].first = sensorTemperatures.dro.isValid(); + sensors[1].second = sensorTemperatures.dro.value; + sensors[2].first = sensorTemperatures.mpa.isValid(); + sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits); if (componentAboveUpperLimit and not camTooHotOneShotFlag) { @@ -1359,12 +1369,12 @@ void ThermalController::ctrlCameraBody() { void ThermalController::ctrlDro() { thermalComponent = DRO; - sensors[0].first = sensorTemperatures.sensor_dro.isValid(); - sensors[0].second = sensorTemperatures.sensor_dro.value; - sensors[1].first = sensorTemperatures.sensor_4k_camera.isValid(); - sensors[1].second = sensorTemperatures.sensor_4k_camera.value; - sensors[2].first = sensorTemperatures.sensor_mpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_mpa.value; + sensors[0].first = sensorTemperatures.dro.isValid(); + sensors[0].second = sensorTemperatures.dro.value; + sensors[1].first = sensorTemperatures.payload4kCamera.isValid(); + sensors[1].second = sensorTemperatures.payload4kCamera.value; + sensors[2].first = sensorTemperatures.mpa.isValid(); + sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1376,8 +1386,8 @@ void ThermalController::ctrlX8() { sensors[0].second = sensorTemperatures.sensor_x8.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); sensors[1].second = sensorTemperatures.sensor_hpa.value; - sensors[2].first = sensorTemperatures.sensor_tx_modul.isValid(); - sensors[2].second = sensorTemperatures.sensor_tx_modul.value; + sensors[2].first = sensorTemperatures.eBandTx.isValid(); + sensors[2].second = sensorTemperatures.eBandTx.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1385,12 +1395,12 @@ void ThermalController::ctrlX8() { void ThermalController::ctrlTx() { thermalComponent = TX; - sensors[0].first = sensorTemperatures.sensor_tx_modul.isValid(); - sensors[0].second = sensorTemperatures.sensor_tx_modul.value; + sensors[0].first = sensorTemperatures.eBandTx.isValid(); + sensors[0].second = sensorTemperatures.eBandTx.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); sensors[1].second = sensorTemperatures.sensor_x8.value; - sensors[2].first = sensorTemperatures.sensor_mpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_mpa.value; + sensors[2].first = sensorTemperatures.mpa.isValid(); + sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1398,12 +1408,12 @@ void ThermalController::ctrlTx() { void ThermalController::ctrlMpa() { thermalComponent = MPA; - sensors[0].first = sensorTemperatures.sensor_mpa.isValid(); - sensors[0].second = sensorTemperatures.sensor_mpa.value; + sensors[0].first = sensorTemperatures.mpa.isValid(); + sensors[0].second = sensorTemperatures.mpa.value; sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); sensors[1].second = sensorTemperatures.sensor_hpa.value; - sensors[2].first = sensorTemperatures.sensor_tx_modul.isValid(); - sensors[2].second = sensorTemperatures.sensor_tx_modul.value; + sensors[2].first = sensorTemperatures.eBandTx.isValid(); + sensors[2].second = sensorTemperatures.eBandTx.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1415,8 +1425,8 @@ void ThermalController::ctrlHpa() { sensors[0].second = sensorTemperatures.sensor_hpa.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); sensors[1].second = sensorTemperatures.sensor_x8.value; - sensors[2].first = sensorTemperatures.sensor_mpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_mpa.value; + sensors[2].first = sensorTemperatures.mpa.isValid(); + sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, hpaLimits); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1424,8 +1434,8 @@ void ThermalController::ctrlHpa() { void ThermalController::ctrlScexBoard() { thermalComponent = SCEX_BOARD; - sensors[0].first = sensorTemperatures.sensor_scex.isValid(); - sensors[0].second = sensorTemperatures.sensor_scex.value; + sensors[0].first = sensorTemperatures.scex.isValid(); + sensors[0].second = sensorTemperatures.scex.value; sensors[1].first = sensorTemperatures.sensor_x8.isValid(); sensors[1].second = sensorTemperatures.sensor_x8.value; sensors[2].first = sensorTemperatures.sensor_hpa.isValid(); @@ -1608,6 +1618,7 @@ uint32_t ThermalController::tempFloatToU32() const { sizeof(tempRaw), SerializeIF::Endianness::NETWORK); return tempRaw; } + void ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { if (componentAboveUpperLimit and not oneShotFlag) { EventManagerIF::triggerEvent(object, overHeatEventToTrigger, tempFloatToU32()); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index fc3c9e4b..aed89cde 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -117,22 +117,22 @@ class ThermalController : public ExtendedControllerBase { DeviceHandlerThermalSet imtqThermalSet; // Temperature Sensors - MAX31865::PrimarySet max31865Set0; - MAX31865::PrimarySet max31865Set1; - MAX31865::PrimarySet max31865Set2; - MAX31865::PrimarySet max31865Set3; - MAX31865::PrimarySet max31865Set4; - MAX31865::PrimarySet max31865Set5; - MAX31865::PrimarySet max31865Set6; - MAX31865::PrimarySet max31865Set7; - MAX31865::PrimarySet max31865Set8; - MAX31865::PrimarySet max31865Set9; - MAX31865::PrimarySet max31865Set10; - MAX31865::PrimarySet max31865Set11; - MAX31865::PrimarySet max31865Set12; - MAX31865::PrimarySet max31865Set13; - MAX31865::PrimarySet max31865Set14; - MAX31865::PrimarySet max31865Set15; + MAX31865::PrimarySet maxSet1PlocHspd; + MAX31865::PrimarySet maxSet0PlocMissionBrd; + MAX31865::PrimarySet maxSet2PlCam; + MAX31865::PrimarySet maxSet3DacHspd; + MAX31865::PrimarySet maxSet4Str; + MAX31865::PrimarySet maxSet5Rw1MxMy; + MAX31865::PrimarySet maxSet6Dro; + MAX31865::PrimarySet maxSet7Scex; + MAX31865::PrimarySet maxSet8X8; + MAX31865::PrimarySet maxSet9Hpa; + MAX31865::PrimarySet maxSet10EbandTx; + MAX31865::PrimarySet maxSet11Mpa; + MAX31865::PrimarySet maxSet31865Set12; + MAX31865::PrimarySet maxSet13PlPcduHspd; + MAX31865::PrimarySet maxSet14TcsBrd; + MAX31865::PrimarySet maxSet15Imtq; TMP1075::Tmp1075Dataset tmp1075SetTcs0; TMP1075::Tmp1075Dataset tmp1075SetTcs1; diff --git a/mission/controller/controllerdefinitions/tcsCtrlDefs.h b/mission/controller/controllerdefinitions/tcsCtrlDefs.h index 6644199f..7ef0690c 100644 --- a/mission/controller/controllerdefinitions/tcsCtrlDefs.h +++ b/mission/controller/controllerdefinitions/tcsCtrlDefs.h @@ -108,21 +108,20 @@ class SensorTemperatures : public StaticLocalDataSet sensor_ploc_heatspreader = + lp_var_t plocHeatspreader = lp_var_t(sid.objectId, PoolIds::SENSOR_PLOC_HEATSPREADER, this); - lp_var_t sensor_ploc_missionboard = + lp_var_t plocMissionboard = lp_var_t(sid.objectId, PoolIds::SENSOR_PLOC_MISSIONBOARD, this); - lp_var_t sensor_4k_camera = lp_var_t(sid.objectId, PoolIds::SENSOR_4K_CAMERA, this); - lp_var_t sensor_dac_heatspreader = + lp_var_t payload4kCamera = lp_var_t(sid.objectId, PoolIds::SENSOR_4K_CAMERA, this); + lp_var_t dacHeatspreader = lp_var_t(sid.objectId, PoolIds::SENSOR_DAC_HEATSPREADER, this); - lp_var_t sensor_startracker = - lp_var_t(sid.objectId, PoolIds::SENSOR_STARTRACKER, this); - lp_var_t sensor_rw1 = lp_var_t(sid.objectId, PoolIds::SENSOR_RW1, this); - lp_var_t sensor_scex = lp_var_t(sid.objectId, PoolIds::SENSOR_SCEX, this); - lp_var_t sensor_tx_modul = lp_var_t(sid.objectId, PoolIds::SENSOR_TX_MODUL, this); + lp_var_t startracker = lp_var_t(sid.objectId, PoolIds::SENSOR_STARTRACKER, this); + lp_var_t rw1 = lp_var_t(sid.objectId, PoolIds::SENSOR_RW1, this); + lp_var_t scex = lp_var_t(sid.objectId, PoolIds::SENSOR_SCEX, this); + lp_var_t eBandTx = lp_var_t(sid.objectId, PoolIds::SENSOR_TX_MODUL, this); // E-Band module - lp_var_t sensor_dro = lp_var_t(sid.objectId, PoolIds::SENSOR_DRO, this); - lp_var_t sensor_mpa = lp_var_t(sid.objectId, PoolIds::SENSOR_MPA, this); + lp_var_t dro = lp_var_t(sid.objectId, PoolIds::SENSOR_DRO, this); + lp_var_t mpa = lp_var_t(sid.objectId, PoolIds::SENSOR_MPA, this); lp_var_t sensor_x8 = lp_var_t(sid.objectId, PoolIds::SENSOR_X8, this); lp_var_t sensor_hpa = lp_var_t(sid.objectId, PoolIds::SENSOR_HPA, this); lp_var_t sensor_acu = lp_var_t(sid.objectId, PoolIds::SENSOR_ACU, this); -- 2.43.0 From da7c450e06fb7cd5df0c9680126630de585dfea9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:00:06 +0100 Subject: [PATCH 22/51] most temps should be valid now --- dummies/Max31865Dummy.cpp | 3 +- dummies/Tmp1075Dummy.cpp | 2 +- mission/controller/ThermalController.cpp | 113 +++++++++--------- .../controllerdefinitions/tcsCtrlDefs.h | 13 +- 4 files changed, 65 insertions(+), 66 deletions(-) diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index ae4026ba..6ec1a716 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -30,7 +30,8 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD LocalDataPoolManager &poolManager) { using namespace MAX31865; localDataPoolMap.emplace(static_cast(PoolIds::RTD_VALUE), new PoolEntry({0})); - localDataPoolMap.emplace(static_cast(PoolIds::TEMPERATURE_C), new PoolEntry({0})); + localDataPoolMap.emplace(static_cast(PoolIds::TEMPERATURE_C), + new PoolEntry({10.0}, true)); localDataPoolMap.emplace(static_cast(PoolIds::LAST_FAULT_BYTE), new PoolEntry({0})); localDataPoolMap.emplace(static_cast(PoolIds::FAULT_BYTE), new PoolEntry({0})); diff --git a/dummies/Tmp1075Dummy.cpp b/dummies/Tmp1075Dummy.cpp index ceca2c52..213a29f4 100644 --- a/dummies/Tmp1075Dummy.cpp +++ b/dummies/Tmp1075Dummy.cpp @@ -36,7 +36,7 @@ void Tmp1075Dummy::fillCommandAndReplyMap() {} uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } ReturnValue_t Tmp1075Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075, new PoolEntry({0.0})); + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075, new PoolEntry({10.0}, true)); return OK; } LocalPoolDataSetBase *Tmp1075Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index a30ac08f..9e698c74 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -341,10 +341,10 @@ void ThermalController::copySensors() { { PoolReadGuard pg8(&maxSet8X8, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg8.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_x8.value = maxSet8X8.temperatureCelcius.value; - sensorTemperatures.sensor_x8.setValid(maxSet8X8.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_x8.isValid()) { - sensorTemperatures.sensor_x8.value = INVALID_TEMPERATURE; + sensorTemperatures.x8.value = maxSet8X8.temperatureCelcius.value; + sensorTemperatures.x8.setValid(maxSet8X8.temperatureCelcius.isValid()); + if (not sensorTemperatures.x8.isValid()) { + sensorTemperatures.x8.value = INVALID_TEMPERATURE; } } } @@ -352,10 +352,10 @@ void ThermalController::copySensors() { { PoolReadGuard pg9(&maxSet9Hpa, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg9.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_hpa.value = maxSet9Hpa.temperatureCelcius.value; - sensorTemperatures.sensor_hpa.setValid(maxSet9Hpa.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_hpa.isValid()) { - sensorTemperatures.sensor_hpa.value = INVALID_TEMPERATURE; + sensorTemperatures.hpa.value = maxSet9Hpa.temperatureCelcius.value; + sensorTemperatures.hpa.setValid(maxSet9Hpa.temperatureCelcius.isValid()); + if (not sensorTemperatures.hpa.isValid()) { + sensorTemperatures.hpa.value = INVALID_TEMPERATURE; } } } @@ -385,10 +385,10 @@ void ThermalController::copySensors() { { PoolReadGuard pg12(&maxSet31865Set12, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg12.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_acu.value = maxSet31865Set12.temperatureCelcius.value; - sensorTemperatures.sensor_acu.setValid(maxSet31865Set12.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_acu.isValid()) { - sensorTemperatures.sensor_acu.value = INVALID_TEMPERATURE; + sensorTemperatures.acu.value = maxSet31865Set12.temperatureCelcius.value; + sensorTemperatures.acu.setValid(maxSet31865Set12.temperatureCelcius.isValid()); + if (not sensorTemperatures.acu.isValid()) { + sensorTemperatures.acu.value = INVALID_TEMPERATURE; } } } @@ -396,12 +396,11 @@ void ThermalController::copySensors() { { PoolReadGuard pg13(&maxSet13PlPcduHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg13.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_plpcdu_heatspreader.value = - maxSet13PlPcduHspd.temperatureCelcius.value; - sensorTemperatures.sensor_plpcdu_heatspreader.setValid( + sensorTemperatures.plpcduHeatspreader.value = maxSet13PlPcduHspd.temperatureCelcius.value; + sensorTemperatures.plpcduHeatspreader.setValid( maxSet13PlPcduHspd.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { - sensorTemperatures.sensor_plpcdu_heatspreader.value = INVALID_TEMPERATURE; + if (not sensorTemperatures.plpcduHeatspreader.isValid()) { + sensorTemperatures.plpcduHeatspreader.value = INVALID_TEMPERATURE; } } } @@ -409,10 +408,10 @@ void ThermalController::copySensors() { { PoolReadGuard pg14(&maxSet14TcsBrd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg14.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_tcs_board.value = maxSet14TcsBrd.temperatureCelcius.value; - sensorTemperatures.sensor_tcs_board.setValid(maxSet14TcsBrd.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_tcs_board.isValid()) { - sensorTemperatures.sensor_tcs_board.value = INVALID_TEMPERATURE; + sensorTemperatures.tcsBoard.value = maxSet14TcsBrd.temperatureCelcius.value; + sensorTemperatures.tcsBoard.setValid(maxSet14TcsBrd.temperatureCelcius.isValid()); + if (not sensorTemperatures.tcsBoard.isValid()) { + sensorTemperatures.tcsBoard.value = INVALID_TEMPERATURE; } } } @@ -420,10 +419,10 @@ void ThermalController::copySensors() { { PoolReadGuard pg15(&maxSet15Imtq, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg15.getReadResult() == returnvalue::OK) { - sensorTemperatures.sensor_magnettorquer.value = maxSet15Imtq.temperatureCelcius.value; - sensorTemperatures.sensor_magnettorquer.setValid(maxSet15Imtq.temperatureCelcius.isValid()); - if (not sensorTemperatures.sensor_magnettorquer.isValid()) { - sensorTemperatures.sensor_magnettorquer.value = INVALID_TEMPERATURE; + sensorTemperatures.mgt.value = maxSet15Imtq.temperatureCelcius.value; + sensorTemperatures.mgt.setValid(maxSet15Imtq.temperatureCelcius.isValid()); + if (not sensorTemperatures.mgt.isValid()) { + sensorTemperatures.mgt.value = INVALID_TEMPERATURE; } } } @@ -977,8 +976,8 @@ void ThermalController::ctrlAcsBoard() { sensors[2].second = deviceTemperatures.mgm0SideA.value; sensors[3].first = deviceTemperatures.mgm2SideB.isValid(); sensors[3].second = deviceTemperatures.mgm2SideB.value; - sensors[4].first = sensorTemperatures.sensor_tcs_board.isValid(); - sensors[5].second = sensorTemperatures.sensor_tcs_board.value; + sensors[4].first = sensorTemperatures.tcsBoard.isValid(); + sensors[5].second = sensorTemperatures.tcsBoard.value; numSensors = 5; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { @@ -995,8 +994,8 @@ void ThermalController::ctrlAcsBoard() { sensors[1].second = deviceTemperatures.mgm2SideB.value; sensors[2].first = deviceTemperatures.gyro3SideB.isValid(); sensors[2].second = deviceTemperatures.gyro3SideB.value; - sensors[3].first = sensorTemperatures.sensor_tcs_board.isValid(); - sensors[3].second = sensorTemperatures.sensor_tcs_board.value; + sensors[3].first = sensorTemperatures.tcsBoard.isValid(); + sensors[3].second = sensorTemperatures.tcsBoard.value; numSensors = 4; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { @@ -1021,12 +1020,12 @@ void ThermalController::ctrlMgt() { static_cast(imtqThermalSet.heaterRequest.value); if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { - sensors[0].first = sensorTemperatures.sensor_magnettorquer.isValid(); - sensors[0].second = sensorTemperatures.sensor_magnettorquer.value; + sensors[0].first = sensorTemperatures.mgt.isValid(); + sensors[0].second = sensorTemperatures.mgt.value; sensors[1].first = deviceTemperatures.mgt.isValid(); sensors[1].second = deviceTemperatures.mgt.value; - sensors[2].first = sensorTemperatures.sensor_plpcdu_heatspreader.isValid(); - sensors[2].second = sensorTemperatures.sensor_plpcdu_heatspreader.value; + 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); } @@ -1144,8 +1143,8 @@ void ThermalController::ctrlIfBoard() { thermalComponent = IF_BOARD; sensors[0].first = sensorTemperatures.tmp1075IfBrd.isValid(); sensors[0].second = sensorTemperatures.tmp1075IfBrd.value; - sensors[1].first = sensorTemperatures.sensor_magnettorquer.isValid(); - sensors[1].second = sensorTemperatures.sensor_magnettorquer.value; + sensors[1].first = sensorTemperatures.mgt.isValid(); + sensors[1].second = sensorTemperatures.mgt.value; sensors[2].first = deviceTemperatures.mgm2SideB.isValid(); sensors[2].second = deviceTemperatures.mgm2SideB.value; numSensors = 3; @@ -1155,8 +1154,8 @@ void ThermalController::ctrlIfBoard() { void ThermalController::ctrlTcsBoard() { thermalComponent = TCS_BOARD; - sensors[0].first = sensorTemperatures.sensor_tcs_board.isValid(); - sensors[0].second = sensorTemperatures.sensor_tcs_board.value; + sensors[0].first = sensorTemperatures.tcsBoard.isValid(); + sensors[0].second = sensorTemperatures.tcsBoard.value; sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); sensors[1].second = sensorTemperatures.tmp1075Tcs0.value; sensors[2].first = sensorTemperatures.tmp1075Tcs1.isValid(); @@ -1250,8 +1249,8 @@ void ThermalController::ctrlPcduAcu() { sensorTemp = deviceTemperatures.acu.value[1]; } else if (deviceTemperatures.acu.value[2] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[2]; - } else if (sensorTemperatures.sensor_acu.isValid()) { - sensorTemp = sensorTemperatures.sensor_acu.value; + } else if (sensorTemperatures.acu.isValid()) { + sensorTemp = sensorTemperatures.acu.value; } else { triggerEvent(tcsCtrl::NO_VALID_SENSOR_TEMPERATURE, thermalComponent); sensorTempAvailable = false; @@ -1294,8 +1293,8 @@ void ThermalController::ctrlPlPcduBoard() { sensors[1].second = sensorTemperatures.tmp1075PlPcdu1.value; sensors[2].first = deviceTemperatures.adcPayloadPcdu.isValid(); sensors[2].second = deviceTemperatures.adcPayloadPcdu.value; - sensors[3].first = sensorTemperatures.sensor_plpcdu_heatspreader.isValid(); - sensors[3].second = sensorTemperatures.sensor_plpcdu_heatspreader.value; + 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); tooHotHandler(objects::PLPCDU_HANDLER, eBandTooHotFlag); @@ -1382,10 +1381,10 @@ void ThermalController::ctrlDro() { void ThermalController::ctrlX8() { thermalComponent = X8; - sensors[0].first = sensorTemperatures.sensor_x8.isValid(); - sensors[0].second = sensorTemperatures.sensor_x8.value; - sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); - sensors[1].second = sensorTemperatures.sensor_hpa.value; + sensors[0].first = sensorTemperatures.x8.isValid(); + sensors[0].second = sensorTemperatures.x8.value; + sensors[1].first = sensorTemperatures.hpa.isValid(); + sensors[1].second = sensorTemperatures.hpa.value; sensors[2].first = sensorTemperatures.eBandTx.isValid(); sensors[2].second = sensorTemperatures.eBandTx.value; numSensors = 3; @@ -1397,8 +1396,8 @@ void ThermalController::ctrlTx() { thermalComponent = TX; sensors[0].first = sensorTemperatures.eBandTx.isValid(); sensors[0].second = sensorTemperatures.eBandTx.value; - sensors[1].first = sensorTemperatures.sensor_x8.isValid(); - sensors[1].second = sensorTemperatures.sensor_x8.value; + sensors[1].first = sensorTemperatures.x8.isValid(); + sensors[1].second = sensorTemperatures.x8.value; sensors[2].first = sensorTemperatures.mpa.isValid(); sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; @@ -1410,8 +1409,8 @@ void ThermalController::ctrlMpa() { thermalComponent = MPA; sensors[0].first = sensorTemperatures.mpa.isValid(); sensors[0].second = sensorTemperatures.mpa.value; - sensors[1].first = sensorTemperatures.sensor_hpa.isValid(); - sensors[1].second = sensorTemperatures.sensor_hpa.value; + sensors[1].first = sensorTemperatures.hpa.isValid(); + sensors[1].second = sensorTemperatures.hpa.value; sensors[2].first = sensorTemperatures.eBandTx.isValid(); sensors[2].second = sensorTemperatures.eBandTx.value; numSensors = 3; @@ -1421,10 +1420,10 @@ void ThermalController::ctrlMpa() { void ThermalController::ctrlHpa() { thermalComponent = HPA; - sensors[0].first = sensorTemperatures.sensor_hpa.isValid(); - sensors[0].second = sensorTemperatures.sensor_hpa.value; - sensors[1].first = sensorTemperatures.sensor_x8.isValid(); - sensors[1].second = sensorTemperatures.sensor_x8.value; + sensors[0].first = sensorTemperatures.hpa.isValid(); + sensors[0].second = sensorTemperatures.hpa.value; + sensors[1].first = sensorTemperatures.x8.isValid(); + sensors[1].second = sensorTemperatures.x8.value; sensors[2].first = sensorTemperatures.mpa.isValid(); sensors[2].second = sensorTemperatures.mpa.value; numSensors = 3; @@ -1436,10 +1435,10 @@ void ThermalController::ctrlScexBoard() { thermalComponent = SCEX_BOARD; sensors[0].first = sensorTemperatures.scex.isValid(); sensors[0].second = sensorTemperatures.scex.value; - sensors[1].first = sensorTemperatures.sensor_x8.isValid(); - sensors[1].second = sensorTemperatures.sensor_x8.value; - sensors[2].first = sensorTemperatures.sensor_hpa.isValid(); - sensors[2].second = sensorTemperatures.sensor_hpa.value; + sensors[1].first = sensorTemperatures.x8.isValid(); + sensors[1].second = sensorTemperatures.x8.value; + sensors[2].first = sensorTemperatures.hpa.isValid(); + sensors[2].second = sensorTemperatures.hpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); tooHotHandler(objects::SCEX, scexTooHotFlag); diff --git a/mission/controller/controllerdefinitions/tcsCtrlDefs.h b/mission/controller/controllerdefinitions/tcsCtrlDefs.h index 7ef0690c..321a9c71 100644 --- a/mission/controller/controllerdefinitions/tcsCtrlDefs.h +++ b/mission/controller/controllerdefinitions/tcsCtrlDefs.h @@ -122,14 +122,13 @@ class SensorTemperatures : public StaticLocalDataSet dro = lp_var_t(sid.objectId, PoolIds::SENSOR_DRO, this); lp_var_t mpa = lp_var_t(sid.objectId, PoolIds::SENSOR_MPA, this); - lp_var_t sensor_x8 = lp_var_t(sid.objectId, PoolIds::SENSOR_X8, this); - lp_var_t sensor_hpa = lp_var_t(sid.objectId, PoolIds::SENSOR_HPA, this); - lp_var_t sensor_acu = lp_var_t(sid.objectId, PoolIds::SENSOR_ACU, this); - lp_var_t sensor_plpcdu_heatspreader = + lp_var_t x8 = lp_var_t(sid.objectId, PoolIds::SENSOR_X8, this); + lp_var_t hpa = lp_var_t(sid.objectId, PoolIds::SENSOR_HPA, this); + lp_var_t acu = lp_var_t(sid.objectId, PoolIds::SENSOR_ACU, this); + lp_var_t plpcduHeatspreader = lp_var_t(sid.objectId, PoolIds::SENSOR_PLPCDU_HEATSPREADER, this); - lp_var_t sensor_tcs_board = lp_var_t(sid.objectId, PoolIds::SENSOR_TCS_BOARD, this); - lp_var_t sensor_magnettorquer = - lp_var_t(sid.objectId, PoolIds::SENSOR_MAGNETTORQUER, this); + lp_var_t tcsBoard = lp_var_t(sid.objectId, PoolIds::SENSOR_TCS_BOARD, this); + lp_var_t mgt = lp_var_t(sid.objectId, PoolIds::SENSOR_MAGNETTORQUER, this); lp_var_t tmp1075Tcs0 = lp_var_t(sid.objectId, PoolIds::SENSOR_TMP1075_TCS_0, this); lp_var_t tmp1075Tcs1 = lp_var_t(sid.objectId, PoolIds::SENSOR_TMP1075_TCS_1, this); lp_var_t tmp1075PlPcdu0 = -- 2.43.0 From 50a62b924338a774311dd8bbf9944066f9d730a8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:13:53 +0100 Subject: [PATCH 23/51] sth broke.. --- mission/controller/ThermalController.cpp | 16 ++++++++-------- mission/controller/ThermalController.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 9e698c74..43798fd8 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -26,9 +26,9 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater deviceTemperatures(this), heaterInfo(this), imtqThermalSet(objects::IMTQ_HANDLER, ThermalStateCfg()), - maxSet1PlocHspd(objects::RTD_0_IC3_PLOC_HEATSPREADER, + maxSet0PlocHspd(objects::RTD_0_IC3_PLOC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), - maxSet0PlocMissionBrd(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + maxSet1PlocMissionBrd(objects::RTD_1_IC4_PLOC_MISSIONBOARD, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), maxSet2PlCam(objects::RTD_2_IC5_4K_CAMERA, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), maxSet3DacHspd(objects::RTD_3_IC6_DAC_HEATSPREADER, @@ -250,10 +250,10 @@ ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode void ThermalController::copySensors() { { - PoolReadGuard pg0(&maxSet1PlocHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg0(&maxSet0PlocHspd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg0.getReadResult() == returnvalue::OK) { - sensorTemperatures.plocHeatspreader.value = maxSet1PlocHspd.temperatureCelcius.value; - sensorTemperatures.plocHeatspreader.setValid(maxSet1PlocHspd.temperatureCelcius.isValid()); + sensorTemperatures.plocHeatspreader.value = maxSet0PlocHspd.temperatureCelcius.value; + sensorTemperatures.plocHeatspreader.setValid(maxSet0PlocHspd.temperatureCelcius.isValid()); if (not sensorTemperatures.plocHeatspreader.isValid()) { sensorTemperatures.plocHeatspreader.value = INVALID_TEMPERATURE; } @@ -261,11 +261,11 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg1(&maxSet0PlocMissionBrd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg1(&maxSet1PlocMissionBrd, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg1.getReadResult() == returnvalue::OK) { - sensorTemperatures.plocMissionboard.value = maxSet0PlocMissionBrd.temperatureCelcius.value; + sensorTemperatures.plocMissionboard.value = maxSet1PlocMissionBrd.temperatureCelcius.value; sensorTemperatures.plocMissionboard.setValid( - maxSet0PlocMissionBrd.temperatureCelcius.isValid()); + maxSet1PlocMissionBrd.temperatureCelcius.isValid()); if (not sensorTemperatures.plocMissionboard.isValid()) { sensorTemperatures.plocMissionboard.value = INVALID_TEMPERATURE; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index aed89cde..c844091b 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -117,8 +117,8 @@ class ThermalController : public ExtendedControllerBase { DeviceHandlerThermalSet imtqThermalSet; // Temperature Sensors - MAX31865::PrimarySet maxSet1PlocHspd; - MAX31865::PrimarySet maxSet0PlocMissionBrd; + MAX31865::PrimarySet maxSet0PlocHspd; + MAX31865::PrimarySet maxSet1PlocMissionBrd; MAX31865::PrimarySet maxSet2PlCam; MAX31865::PrimarySet maxSet3DacHspd; MAX31865::PrimarySet maxSet4Str; -- 2.43.0 From 27f29eda40006d51fa05dbcc54850e4a94e8e7c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:16:12 +0100 Subject: [PATCH 24/51] small error --- mission/controller/ThermalController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 43798fd8..4a4c3469 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -977,7 +977,7 @@ void ThermalController::ctrlAcsBoard() { sensors[3].first = deviceTemperatures.mgm2SideB.isValid(); sensors[3].second = deviceTemperatures.mgm2SideB.value; sensors[4].first = sensorTemperatures.tcsBoard.isValid(); - sensors[5].second = sensorTemperatures.tcsBoard.value; + sensors[4].second = sensorTemperatures.tcsBoard.value; numSensors = 5; if (selectAndReadSensorTemp()) { if (chooseHeater(switchNr, redSwitchNr)) { -- 2.43.0 From dc44af5b2980887355a4caafdee3ceec77a56db0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:20:47 +0100 Subject: [PATCH 25/51] copy and paste error --- mission/controller/ThermalController.cpp | 5 +++-- mission/controller/ThermalController.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 4a4c3469..e22d2b8a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -16,7 +16,8 @@ #include #include -#define LOWER_SYRLINKS_UPPER_LIMITS 0 +// Enabling this should trigger a special event which in turn should trigger a system reaction. +#define LOWER_SYRLINKS_UPPER_LIMITS 1 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), @@ -1216,7 +1217,7 @@ void ThermalController::ctrlSBandTransceiver() { triggerEvent(tcsCtrl::SYRLINKS_OVERHEATING, tempFloatToU32()); syrlinksTooHotFlag = true; } else if (not componentAboveUpperLimit) { - pcduSystemTooHotFlag = false; + syrlinksTooHotFlag = true; } } void ThermalController::ctrlPcduP60Board() { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index c844091b..1102f033 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -164,8 +164,6 @@ class ThermalController : public ExtendedControllerBase { TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 130.0); TempLimits obcLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0); TempLimits obcIfBoardLimits = TempLimits(-65.0, -40.0, 80.0, 85.0, 125.0); - // Limits to test commading to RX Only - // TempLimits sBandTransceiverLimits = TempLimits(-40.0, -25.0, 0.0, 0.0, 5.0); TempLimits sBandTransceiverLimits = TempLimits(-40.0, -25.0, 35.0, 40.0, 65.0); TempLimits pcduP60BoardLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0); TempLimits pcduAcuLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0); -- 2.43.0 From 715a69db893ba61ddd0af4febbcd56cb57d66e07 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:43:20 +0100 Subject: [PATCH 26/51] this should cover upper bound checking when heater is off --- mission/controller/ThermalController.cpp | 58 ++++++++++++++---------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index e22d2b8a..42d79a2a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -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(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(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); + } } } } -- 2.43.0 From 364342855df3ec6e728aa2645bb488c1f9ffb152 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 15:52:20 +0100 Subject: [PATCH 27/51] maybe force a mode command? --- mission/system/objects/EiveSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index f2c6fcff..1c4fce19 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -86,7 +86,7 @@ void EiveSystem::handleEventMessages() { switch (event.getEvent()) { case tcsCtrl::SYRLINKS_OVERHEATING: { CommandMessage msg; - ModeMessage::setCmdModeMessage(msg, com::RX_ONLY, 0); + ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, com::RX_ONLY, 0); ReturnValue_t result = commandQueue->sendMessage(childrenMap[objects::COM_SUBSYSTEM].commandQueue, &msg); if (result != returnvalue::OK) { -- 2.43.0 From 8201a4140ae1f55980865d55bfb5f2e73ee337e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 16:19:37 +0100 Subject: [PATCH 28/51] works better now --- mission/controller/ThermalController.cpp | 24 +++++++++++++++--------- mission/controller/ThermalController.h | 8 +++++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 42d79a2a..c31ff3f8 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -17,7 +17,7 @@ #include // Enabling this should trigger a special event which in turn should trigger a system reaction. -#define LOWER_SYRLINKS_UPPER_LIMITS 1 +#define LOWER_SYRLINKS_UPPER_LIMITS 0 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), @@ -67,11 +67,6 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) { resetSensorsArray(); -#if LOWER_SYRLINKS_UPPER_LIMITS == 1 - sBandTransceiverLimits.cutOffLimit = 0; - sBandTransceiverLimits.opUpperLimit = 0; - sBandTransceiverLimits.nopUpperLimit = 0; -#endif } ReturnValue_t ThermalController::initialize() { @@ -91,6 +86,7 @@ void ThermalController::performControlOperation() { #if OBSW_THREAD_TRACING == 1 trace::threadTrace(opCounter, "TCS Task"); #endif + switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); @@ -99,6 +95,7 @@ void ThermalController::performControlOperation() { } case InternalState::INITIAL_DELAY: { if (initialCountdown.hasTimedOut()) { + sif::info << "Starting thermal control operations" << std::endl; internalState = InternalState::READY; } return; @@ -110,6 +107,14 @@ void ThermalController::performControlOperation() { break; } + if(cycles == 50) { +#if LOWER_SYRLINKS_UPPER_LIMITS == 1 + sBandTransceiverLimits.cutOffLimit = 0; + sBandTransceiverLimits.opUpperLimit = 0; + sBandTransceiverLimits.nopUpperLimit = 0; +#endif + } + { PoolReadGuard pg(&sensorTemperatures); if (pg.getReadResult() == returnvalue::OK) { @@ -143,6 +148,7 @@ void ThermalController::performControlOperation() { } performThermalModuleCtrl(); + cycles++; } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -1217,7 +1223,7 @@ void ThermalController::ctrlSBandTransceiver() { triggerEvent(tcsCtrl::SYRLINKS_OVERHEATING, tempFloatToU32()); syrlinksTooHotFlag = true; } else if (not componentAboveUpperLimit) { - syrlinksTooHotFlag = true; + syrlinksTooHotFlag = false; } } void ThermalController::ctrlPcduP60Board() { @@ -1541,8 +1547,8 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, componentAboveUpperLimit = false; auto tempTooHighHandler = [&](const char* whatLimit, bool heaterIsOn) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Reached " << whatLimit << ": Heater " - << static_cast(thermalComponent) << " OFF" << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Exceeded " << whatLimit << ": " + "Heater for component " << static_cast(thermalComponent) << std::endl; heaterStates[switchNr].switchTransition = true; if (heaterIsOn) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1102f033..9e9ca309 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -97,7 +97,7 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: - static const uint32_t DELAY = 500; + static const uint32_t INIT_DELAY = 3000; static const uint32_t TEMP_OFFSET = 5; @@ -196,11 +196,13 @@ class ThermalController : public ExtendedControllerBase { bool obcTooHotFlag = false; bool strTooHotFlag = false; bool rwTooHotFlag = false; + uint32_t cycles = 0; std::array thermalStates{}; std::array heaterStates{}; - // Initial delay to make sure all pool variables have been initialized their owners - Countdown initialCountdown = Countdown(DELAY); + // Initial delay to make sure all pool variables have been initialized their owners. + // Also, wait for system initialization to complete. + Countdown initialCountdown = Countdown(INIT_DELAY); #if OBSW_THREAD_TRACING == 1 uint32_t opCounter = 0; -- 2.43.0 From 9b8092fb09de253762b0fd6fc14a278c72f5726b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 16:24:01 +0100 Subject: [PATCH 29/51] this seems to work --- mission/controller/ThermalController.cpp | 15 ++++++++------- mission/system/objects/EiveSystem.cpp | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index c31ff3f8..55e7be1b 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -66,7 +66,6 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet10(objects::SUS_10_N_LOC_XMYBZF_PT_ZF), susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) { resetSensorsArray(); - } ReturnValue_t ThermalController::initialize() { @@ -107,11 +106,11 @@ void ThermalController::performControlOperation() { break; } - if(cycles == 50) { + if (cycles == 50) { #if LOWER_SYRLINKS_UPPER_LIMITS == 1 - sBandTransceiverLimits.cutOffLimit = 0; - sBandTransceiverLimits.opUpperLimit = 0; - sBandTransceiverLimits.nopUpperLimit = 0; + sBandTransceiverLimits.cutOffLimit = 0; + sBandTransceiverLimits.opUpperLimit = 0; + sBandTransceiverLimits.nopUpperLimit = 0; #endif } @@ -1547,8 +1546,10 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, componentAboveUpperLimit = false; auto tempTooHighHandler = [&](const char* whatLimit, bool heaterIsOn) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Exceeded " << whatLimit << ": " - "Heater for component " << static_cast(thermalComponent) << std::endl; + sif::info << "ThermalController::checkLimitsAndCtrlHeater: Exceeded " << whatLimit + << ": " + "Heater for component " + << static_cast(thermalComponent) << std::endl; heaterStates[switchNr].switchTransition = true; if (heaterIsOn) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index 1c4fce19..67b79615 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -86,7 +86,8 @@ void EiveSystem::handleEventMessages() { switch (event.getEvent()) { case tcsCtrl::SYRLINKS_OVERHEATING: { CommandMessage msg; - ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, com::RX_ONLY, 0); + ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, com::RX_ONLY, + 0); ReturnValue_t result = commandQueue->sendMessage(childrenMap[objects::COM_SUBSYSTEM].commandQueue, &msg); if (result != returnvalue::OK) { -- 2.43.0 From 11e5866f31bc213d5beac0ec522571b5df7859b2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 16:24:46 +0100 Subject: [PATCH 30/51] added some defines --- mission/controller/ThermalController.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 55e7be1b..f0a747ec 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -18,6 +18,8 @@ // Enabling this should trigger a special event which in turn should trigger a system reaction. #define LOWER_SYRLINKS_UPPER_LIMITS 0 +#define LOWER_EBAND_UPPER_LIMITS 0 +#define LOWER_PLOC_UPPER_LIMITS 0 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), -- 2.43.0 From 350ed59033821f34be053e702e531ea2a132a2c4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 17:13:25 +0100 Subject: [PATCH 31/51] handle syrlinks overheating in COM SS --- mission/system/objects/ComSubsystem.cpp | 15 ++++++++++++++- mission/system/objects/EiveSystem.cpp | 12 ------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index b9ed0a05..1d0d9b32 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -1,5 +1,6 @@ #include "ComSubsystem.h" +#include #include #include #include @@ -7,6 +8,7 @@ #include #include #include +#include #include @@ -93,7 +95,11 @@ ReturnValue_t ComSubsystem::initialize() { "listener" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->subscribeToEvent(eventQueue->getId(), + event::getEventId(tcsCtrl::SYRLINKS_OVERHEATING)); + if (result != returnvalue::OK) { + return ObjectManager::CHILD_INIT_FAILED; } result = manager->subscribeToEventRange(eventQueue->getId(), event::getEventId(PdecHandler::CARRIER_LOCK), @@ -144,6 +150,13 @@ void ComSubsystem::readEventQueue() { void ComSubsystem::handleEventMessage(EventMessage *eventMessage) { Event event = eventMessage->getEvent(); switch (event) { + case tcsCtrl::SYRLINKS_OVERHEATING: { + // TODO: To prevent simply overwriting/cancelling on-going transitions, set flag here and + // execute transition at a later stage. + modeHelper.setForced(true); + startTransition(com::RX_ONLY, 0); + break; + } case PdecHandler::BIT_LOCK_PDEC: { handleBitLockEvent(); break; diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index 67b79615..284beb49 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -69,7 +69,6 @@ ReturnValue_t EiveSystem::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::SYRLINKS_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::PCDU_SYSTEM_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::OBC_OVERHEATING)); @@ -84,17 +83,6 @@ void EiveSystem::handleEventMessages() { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: switch (event.getEvent()) { - case tcsCtrl::SYRLINKS_OVERHEATING: { - CommandMessage msg; - ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, com::RX_ONLY, - 0); - ReturnValue_t result = - commandQueue->sendMessage(childrenMap[objects::COM_SUBSYSTEM].commandQueue, &msg); - if (result != returnvalue::OK) { - sif::error << "EiveSystem: Commanding COM to RX_ONLY failed" << std::endl; - } - break; - } case tcsCtrl::OBC_OVERHEATING: case tcsCtrl::PCDU_SYSTEM_OVERHEATING: { commandSelfToSafe(); -- 2.43.0 From 56a4378a633b2b1afcef089b7a21a91c33f9cc4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 18:05:23 +0100 Subject: [PATCH 32/51] that should be transition safe --- mission/system/objects/ComSubsystem.cpp | 25 +++++++++++++++++++++---- mission/system/objects/ComSubsystem.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index 1d0d9b32..c6a8cfc9 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -24,6 +24,11 @@ ComSubsystem::ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequence void ComSubsystem::performChildOperation() { readEventQueue(); + if (performRecoveryToRxOnly and not isInTransition) { + startRxOnlyRecovery(true); + // To avoid immediately enabling TX after falling back. + rememberBitLock = false; + } // Execute default rate sequence after transition has been completed if (rememberBitLock and not isInTransition) { startRxAndTxLowRateSeq(); @@ -151,10 +156,16 @@ void ComSubsystem::handleEventMessage(EventMessage *eventMessage) { Event event = eventMessage->getEvent(); switch (event) { case tcsCtrl::SYRLINKS_OVERHEATING: { - // TODO: To prevent simply overwriting/cancelling on-going transitions, set flag here and - // execute transition at a later stage. - modeHelper.setForced(true); - startTransition(com::RX_ONLY, 0); + // This event overrides the bit lock. + rememberBitLock = false; + if (mode == com::RX_ONLY) { + return; + } + if (isInTransition) { + performRecoveryToRxOnly = true; + return; + } + startRxOnlyRecovery(true); break; } case PdecHandler::BIT_LOCK_PDEC: { @@ -204,6 +215,12 @@ void ComSubsystem::checkTransmitterCountdown() { } } +void ComSubsystem::startRxOnlyRecovery(bool forced) { + modeHelper.setForced(forced); + startTransition(com::RX_ONLY, 0); + performRecoveryToRxOnly = false; +} + bool ComSubsystem::isTxMode(Mode_t mode) { if ((mode == com::Submode::RX_AND_TX_DEFAULT_DATARATE) || (mode == com::Submode::RX_AND_TX_LOW_DATARATE) || diff --git a/mission/system/objects/ComSubsystem.h b/mission/system/objects/ComSubsystem.h index 854a877b..dbc8eda8 100644 --- a/mission/system/objects/ComSubsystem.h +++ b/mission/system/objects/ComSubsystem.h @@ -57,6 +57,7 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { * @brief Enables transmitter in low rate mode */ void startRxAndTxLowRateSeq(); + void startRxOnlyRecovery(bool forced); /** * @brief Returns true if mode is a mode where the transmitter is on @@ -73,6 +74,7 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { MessageQueueIF *eventQueue = nullptr; bool enableTxWhenCarrierLock = false; + bool performRecoveryToRxOnly = false; // Countdown will be started as soon as the transmitter was enabled Countdown transmitterCountdown; -- 2.43.0 From eda1f7e21239886bc04c5c30d3cbe7af53ad4f7d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 18:28:51 +0100 Subject: [PATCH 33/51] syrlinks event works --- mission/controller/ThermalController.cpp | 2 ++ mission/controller/ThermalController.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f0a747ec..36cb6e8a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -98,6 +98,7 @@ void ThermalController::performControlOperation() { if (initialCountdown.hasTimedOut()) { sif::info << "Starting thermal control operations" << std::endl; internalState = InternalState::READY; + break; } return; } @@ -109,6 +110,7 @@ void ThermalController::performControlOperation() { } if (cycles == 50) { + sif::debug << "ThermalController: changing limits" << std::endl; #if LOWER_SYRLINKS_UPPER_LIMITS == 1 sBandTransceiverLimits.cutOffLimit = 0; sBandTransceiverLimits.opUpperLimit = 0; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 9e9ca309..758ebb86 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -97,7 +97,7 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: - static const uint32_t INIT_DELAY = 3000; + static const uint32_t INIT_DELAY = 1500; static const uint32_t TEMP_OFFSET = 5; -- 2.43.0 From b1d2f73b01820c62a230a76de678da034dc174d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 18:47:51 +0100 Subject: [PATCH 34/51] move Switches enum --- bsp_q7s/core/ObjectFactory.cpp | 10 +-- dummies/PlocMpsocDummy.h | 2 + dummies/helpers.cpp | 4 +- mission/core/GenericFactory.cpp | 4 +- mission/devices/PcduHandler.cpp | 85 ++++++++++--------- mission/devices/PcduHandler.h | 4 +- .../devices/SolarArrayDeploymentHandler.cpp | 2 +- mission/devices/SolarArrayDeploymentHandler.h | 2 +- .../devicedefinitions/GomspaceDefinitions.h | 29 +------ mission/powerDefs.h | 33 +++++++ mission/system/objects/AcsBoardAssembly.h | 4 +- .../system/objects/DualLaneAssemblyBase.cpp | 2 +- mission/system/objects/DualLaneAssemblyBase.h | 4 +- mission/system/objects/Stack5VHandler.h | 2 +- mission/system/objects/SusAssembly.h | 4 +- 15 files changed, 101 insertions(+), 90 deletions(-) create mode 100644 mission/powerDefs.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3afab7cd..1c4fc53a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -585,7 +585,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitc } new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, gpioIF, pwrSwitcher, - pcdu::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, + power::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, gpioIds::DEPLSA1, gpioIds::DEPLSA2, *SdCardManager::instance()); } @@ -600,7 +600,7 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HANDLER); auto syrlinksHandler = new SyrlinksHandler(objects::SYRLINKS_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, - pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); + power::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); syrlinksHandler->setPowerSwitcher(pwrSwitcher); syrlinksHandler->connectModeTreeParent(*syrlinksAssy); #if OBSW_DEBUG_SYRLINKS == 1 @@ -612,7 +612,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit using namespace gpio; std::stringstream consumer; auto* camSwitcher = - new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, pcdu::PDU2_CH8_PAYLOAD_CAMERA); + new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::PDU2_CH8_PAYLOAD_CAMERA); camSwitcher->connectModeTreeParent(satsystem::payload::SUBSYSTEM); #if OBSW_ADD_PLOC_MPSOC == 1 consumer << "0x" << std::hex << objects::PLOC_MPSOC_HANDLER; @@ -943,7 +943,7 @@ void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { auto strFdir = new StrFdir(objects::STAR_TRACKER); auto starTracker = new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, - paramJsonFile, strHelper, pcdu::PDU1_CH2_STAR_TRACKER_5V); + paramJsonFile, strHelper, power::PDU1_CH2_STAR_TRACKER_5V); starTracker->setPowerSwitcher(pwrSwitcher); starTracker->connectModeTreeParent(*strAssy); starTracker->setCustomFdir(strFdir); @@ -956,7 +956,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher) { new ImtqPollingTask(objects::IMTQ_POLLING); I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, q7s::I2C_PL_EIVE); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::IMTQ_POLLING, imtqI2cCookie, - pcdu::Switches::PDU1_CH3_MGT_5V); + power::Switches::PDU1_CH3_MGT_5V); imtqHandler->enableThermalModule(ThermalStateCfg()); imtqHandler->setPowerSwitcher(pwrSwitcher); imtqHandler->connectModeTreeParent(*imtqAssy); diff --git a/dummies/PlocMpsocDummy.h b/dummies/PlocMpsocDummy.h index 7beaa76b..76188624 100644 --- a/dummies/PlocMpsocDummy.h +++ b/dummies/PlocMpsocDummy.h @@ -2,6 +2,8 @@ #include +#include "mission/powerDefs.h" + class PlocMpsocDummy : public DeviceHandlerBase { public: static const DeviceCommandId_t SIMPLE_COMMAND = 1; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 2210e1bb..026590e0 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -56,7 +56,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio rws[1] = new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); rws[2] = new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); rws[3] = new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); - ObjectFactory::createRwAssy(pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); + ObjectFactory::createRwAssy(pwrSwitcher, power::Switches::PDU2_CH2_RW_5V, rws, rwIds); new SaDeplDummy(objects::SOLAR_ARRAY_DEPL_HANDLER); auto* strAssy = new StrAssembly(objects::STR_ASSY); strAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); @@ -210,7 +210,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } } auto* camSwitcher = - new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, pcdu::Switches::PDU2_CH8_PAYLOAD_CAMERA); + new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::Switches::PDU2_CH8_PAYLOAD_CAMERA); camSwitcher->connectModeTreeParent(satsystem::payload::SUBSYSTEM); auto* scexDummy = new ScexDummy(objects::SCEX, objects::DUMMY_COM_IF, comCookieDummy); scexDummy->connectModeTreeParent(satsystem::payload::SUBSYSTEM); diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 53ca6904..94a60f00 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -296,7 +296,7 @@ void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& {new HealthDevice(objects::HEATER_7_SYRLINKS, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_7}, }}); heaterHandler = new HeaterHandler(objects::HEATER_HANDLER, &gpioIF, helper, &pwrSwitcher, - pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); + power::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); heaterHandler->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } @@ -365,7 +365,7 @@ void ObjectFactory::createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, TcsBoardAssembly* ObjectFactory::createTcsBoardAssy(PowerSwitchIF& pwrSwitcher) { TcsBoardHelper helper(RTD_INFOS); auto* tcsBoardAss = new TcsBoardAssembly(objects::TCS_BOARD_ASS, &pwrSwitcher, - pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); + power::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); tcsBoardAss->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); return tcsBoardAss; } diff --git a/mission/devices/PcduHandler.cpp b/mission/devices/PcduHandler.cpp index f5873fcf..1ae3a68d 100644 --- a/mission/devices/PcduHandler.cpp +++ b/mission/devices/PcduHandler.cpp @@ -40,9 +40,9 @@ ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { PoolReadGuard pg(&switcherSet.p60Dock5VStack); if (pg.getReadResult() == returnvalue::OK) { if (switcherSet.p60Dock5VStack.value != switchState) { - triggerEvent(power::SWITCH_HAS_CHANGED, switchState, pcdu::Switches::P60_DOCK_5V_STACK); + triggerEvent(power::SWITCH_HAS_CHANGED, switchState, power::Switches::P60_DOCK_5V_STACK); MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - switchStates[pcdu::P60_DOCK_5V_STACK] = switchState; + switchStates[power::P60_DOCK_5V_STACK] = switchState; } switcherSet.p60Dock5VStack.setValid(true); switcherSet.p60Dock5VStack.value = switchState; @@ -102,7 +102,7 @@ ReturnValue_t PCDUHandler::initialize() { void PCDUHandler::initializeSwitchStates() { using namespace pcdu; try { - for (uint8_t idx = 0; idx < NUMBER_OF_SWITCHES; idx++) { + for (uint8_t idx = 0; idx < power::NUMBER_OF_SWITCHES; idx++) { if (idx < PDU::CHANNELS_LEN) { switchStates[idx] = INIT_SWITCHES_PDU1.at(idx); } else if (idx < PDU::CHANNELS_LEN * 2) { @@ -180,22 +180,23 @@ void PCDUHandler::updatePdu2SwitchStates() { } switcherSet.pdu2Switches.setValid(true); MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH0_Q7S, pdu2CoreHk.outputEnables[Channels::Q7S]); + checkAndUpdatePduSwitch(pdu, power::PDU2_CH0_Q7S, pdu2CoreHk.outputEnables[Channels::Q7S]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, pdu2CoreHk.outputEnables[Channels::PAYLOAD_PCDU_CH1]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH2_RW_5V, pdu2CoreHk.outputEnables[Channels::RW]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH2_RW_5V, + pdu2CoreHk.outputEnables[Channels::RW]); + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V, pdu2CoreHk.outputEnables[Channels::TCS_HEATER_IN]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH4_SUS_REDUNDANT_3V3, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH4_SUS_REDUNDANT_3V3, pdu2CoreHk.outputEnables[Channels::SUS_REDUNDANT]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, pdu2CoreHk.outputEnables[Channels::DEPY_MECHANISM]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, pdu2CoreHk.outputEnables[Channels::PAYLOAD_PCDU_CH6]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3, pdu2CoreHk.outputEnables[Channels::ACS_B_SIDE]); - checkAndUpdatePduSwitch(pdu, Switches::PDU2_CH8_PAYLOAD_CAMERA, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU2_CH8_PAYLOAD_CAMERA, pdu2CoreHk.outputEnables[Channels::PAYLOAD_CAMERA]); if (firstSwitchInfoPdu2) { firstSwitchInfoPdu2 = false; @@ -217,23 +218,23 @@ void PCDUHandler::updatePdu1SwitchStates() { } switcherSet.pdu1Switches.setValid(true); MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH0_TCS_BOARD_3V3, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH0_TCS_BOARD_3V3, pdu1CoreHk.outputEnables[Channels::TCS_BOARD_3V3]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH1_SYRLINKS_12V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH1_SYRLINKS_12V, pdu1CoreHk.outputEnables[Channels::SYRLINKS]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH2_STAR_TRACKER_5V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH2_STAR_TRACKER_5V, pdu1CoreHk.outputEnables[Channels::STR]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH3_MGT_5V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH3_MGT_5V, pdu1CoreHk.outputEnables[Channels::MGT]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH4_SUS_NOMINAL_3V3, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH4_SUS_NOMINAL_3V3, pdu1CoreHk.outputEnables[Channels::SUS_NOMINAL]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH5_SOLAR_CELL_EXP_5V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V, pdu1CoreHk.outputEnables[Channels::SOL_CELL_EXPERIMENT]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH6_PLOC_12V, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH6_PLOC_12V, pdu1CoreHk.outputEnables[Channels::PLOC]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH7_ACS_A_SIDE_3V3, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH7_ACS_A_SIDE_3V3, pdu1CoreHk.outputEnables[Channels::ACS_A_SIDE]); - checkAndUpdatePduSwitch(pdu, Switches::PDU1_CH8_UNOCCUPIED, + checkAndUpdatePduSwitch(pdu, power::Switches::PDU1_CH8_UNOCCUPIED, pdu1CoreHk.outputEnables[Channels::UNUSED]); if (firstSwitchInfoPdu1) { firstSwitchInfoPdu1 = false; @@ -254,99 +255,99 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO GomspaceDeviceHandler* module = nullptr; switch (switchNr) { - case pcdu::PDU1_CH0_TCS_BOARD_3V3: { + case power::PDU1_CH0_TCS_BOARD_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH1_SYRLINKS_12V: { + case power::PDU1_CH1_SYRLINKS_12V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SYRLINKS; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH2_STAR_TRACKER_5V: { + case power::PDU1_CH2_STAR_TRACKER_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_STAR_TRACKER; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH3_MGT_5V: { + case power::PDU1_CH3_MGT_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_MGT; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH4_SUS_NOMINAL_3V3: { + case power::PDU1_CH4_SUS_NOMINAL_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH5_SOLAR_CELL_EXP_5V: { + case power::PDU1_CH5_SOLAR_CELL_EXP_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH6_PLOC_12V: { + case power::PDU1_CH6_PLOC_12V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_PLOC; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH7_ACS_A_SIDE_3V3: { + case power::PDU1_CH7_ACS_A_SIDE_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcdu::PDU1_CH8_UNOCCUPIED: { + case power::PDU1_CH8_UNOCCUPIED: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_CHANNEL8; module = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } // This is a dangerous command. Reject/Igore it for now - case pcdu::PDU2_CH0_Q7S: { + case power::PDU2_CH0_Q7S: { return returnvalue::FAILED; // memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_Q7S; // pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); // break; } - case pcdu::PDU2_CH1_PL_PCDU_BATT_0_14V8: { + case power::PDU2_CH1_PL_PCDU_BATT_0_14V8: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH2_RW_5V: { + case power::PDU2_CH2_RW_5V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_RW; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH3_TCS_BOARD_HEATER_IN_8V: { + case power::PDU2_CH3_TCS_BOARD_HEATER_IN_8V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH4_SUS_REDUNDANT_3V3: { + case power::PDU2_CH4_SUS_REDUNDANT_3V3: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH5_DEPLOYMENT_MECHANISM_8V: { + case power::PDU2_CH5_DEPLOYMENT_MECHANISM_8V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH6_PL_PCDU_BATT_1_14V8: { + case power::PDU2_CH6_PL_PCDU_BATT_1_14V8: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH7_ACS_BOARD_SIDE_B_3V3: { + case power::PDU2_CH7_ACS_BOARD_SIDE_B_3V3: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::PDU2_CH8_PAYLOAD_CAMERA: { + case power::PDU2_CH8_PAYLOAD_CAMERA: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA; module = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcdu::P60_DOCK_5V_STACK: { + case power::P60_DOCK_5V_STACK: { memoryAddress = P60Dock::CONFIG_ADDRESS_OUT_EN_5V_STACK; module = ObjectManager::instance()->get(objects::P60DOCK_HANDLER); break; @@ -398,7 +399,7 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { return returnvalue::OK; } ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { - if (switchNr >= pcdu::NUMBER_OF_SWITCHES) { + if (switchNr >= power::NUMBER_OF_SWITCHES) { sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; return returnvalue::FAILED; } @@ -455,7 +456,7 @@ LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { } } -void PCDUHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, +void PCDUHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, power::Switches switchIdx, uint8_t setValue) { using namespace pcdu; if (switchStates[switchIdx] != setValue) { diff --git a/mission/devices/PcduHandler.h b/mission/devices/PcduHandler.h index 45bbd392..fe739b92 100644 --- a/mission/devices/PcduHandler.h +++ b/mission/devices/PcduHandler.h @@ -84,7 +84,7 @@ class PCDUHandler : public PowerSwitchIF, /** The timeStamp of the current pdu1HkTableDataset */ CCSDSTime::CDS_short timeStampPdu1HkDataset; - uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES]; + uint8_t switchStates[power::NUMBER_OF_SWITCHES]; /** * Pointer to the IPCStore. * This caches the pointer received from the objectManager in the constructor. @@ -133,7 +133,7 @@ class PCDUHandler : public PowerSwitchIF, */ void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp); - void checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue); + void checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, power::Switches switchIdx, uint8_t setValue); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index e4356630..01dcb3c4 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -18,7 +18,7 @@ static constexpr bool DEBUG_MODE = true; SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, GpioIF& gpioInterface, PowerSwitchIF& mainLineSwitcher_, - pcdu::Switches mainLineSwitch_, + power::Switches mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, SdCardMountedIF& sdcMountedIF) : SystemObject(setObjectId_), diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 61211ca3..b8983225 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -107,7 +107,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, * @param burnTimeMs Time duration the power will be applied to the burn wires. */ SolarArrayDeploymentHandler(object_id_t setObjectId, GpioIF& gpio, - PowerSwitchIF& mainLineSwitcher, pcdu::Switches mainLineSwitch, + PowerSwitchIF& mainLineSwitcher, power::Switches mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2, SdCardMountedIF& sdcMountedIF); virtual ~SolarArrayDeploymentHandler(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 75a81d8f..aa8e12ee 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -11,6 +11,7 @@ #include "devices/powerSwitcherList.h" #include "fsfw/platform.h" #include "gomspaceDefines.h" +#include "mission/powerDefs.h" namespace GOMSPACE { @@ -715,32 +716,6 @@ namespace pcdu { enum PoolIds : uint32_t { PDU1_SWITCHES, PDU2_SWITCHES, P60DOCK_SWITCHES }; -/* Switches are uint8_t datatype and go from 0 to 255 */ -enum Switches : power::Switch_t { - PDU1_CH0_TCS_BOARD_3V3, - PDU1_CH1_SYRLINKS_12V, - PDU1_CH2_STAR_TRACKER_5V, - PDU1_CH3_MGT_5V, - PDU1_CH4_SUS_NOMINAL_3V3, - PDU1_CH5_SOLAR_CELL_EXP_5V, - PDU1_CH6_PLOC_12V, - PDU1_CH7_ACS_A_SIDE_3V3, - PDU1_CH8_UNOCCUPIED, - - PDU2_CH0_Q7S, - PDU2_CH1_PL_PCDU_BATT_0_14V8, - PDU2_CH2_RW_5V, - PDU2_CH3_TCS_BOARD_HEATER_IN_8V, - PDU2_CH4_SUS_REDUNDANT_3V3, - PDU2_CH5_DEPLOYMENT_MECHANISM_8V, - PDU2_CH6_PL_PCDU_BATT_1_14V8, - PDU2_CH7_ACS_BOARD_SIDE_B_3V3, - PDU2_CH8_PAYLOAD_CAMERA, - - P60_DOCK_5V_STACK, - NUMBER_OF_SWITCHES -}; - static const uint8_t ON = 1; static const uint8_t OFF = 0; @@ -760,7 +735,7 @@ const std::array INIT_SWITCHES_PDU2 = {ON, OFF, OFF static constexpr uint32_t SWITCHER_SET_ID = 0; -class SwitcherStates : public StaticLocalDataSet { +class SwitcherStates : public StaticLocalDataSet { public: SwitcherStates(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SWITCHER_SET_ID) {} diff --git a/mission/powerDefs.h b/mission/powerDefs.h new file mode 100644 index 00000000..b4d5b9db --- /dev/null +++ b/mission/powerDefs.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace power { + +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum Switches : power::Switch_t { + PDU1_CH0_TCS_BOARD_3V3, + PDU1_CH1_SYRLINKS_12V, + PDU1_CH2_STAR_TRACKER_5V, + PDU1_CH3_MGT_5V, + PDU1_CH4_SUS_NOMINAL_3V3, + PDU1_CH5_SOLAR_CELL_EXP_5V, + PDU1_CH6_PLOC_12V, + PDU1_CH7_ACS_A_SIDE_3V3, + PDU1_CH8_UNOCCUPIED, + + PDU2_CH0_Q7S, + PDU2_CH1_PL_PCDU_BATT_0_14V8, + PDU2_CH2_RW_5V, + PDU2_CH3_TCS_BOARD_HEATER_IN_8V, + PDU2_CH4_SUS_REDUNDANT_3V3, + PDU2_CH5_DEPLOYMENT_MECHANISM_8V, + PDU2_CH6_PL_PCDU_BATT_1_14V8, + PDU2_CH7_ACS_BOARD_SIDE_B_3V3, + PDU2_CH8_PAYLOAD_CAMERA, + + P60_DOCK_5V_STACK, + NUMBER_OF_SWITCHES +}; + +} // namespace power diff --git a/mission/system/objects/AcsBoardAssembly.h b/mission/system/objects/AcsBoardAssembly.h index a07431fe..2c9c6fdf 100644 --- a/mission/system/objects/AcsBoardAssembly.h +++ b/mission/system/objects/AcsBoardAssembly.h @@ -105,8 +105,8 @@ class AcsBoardAssembly : public DualLaneAssemblyBase { void selectGpsInDualMode(duallane::Submodes side); private: - static constexpr pcdu::Switches SWITCH_A = pcdu::Switches::PDU1_CH7_ACS_A_SIDE_3V3; - static constexpr pcdu::Switches SWITCH_B = pcdu::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; + static constexpr power::Switches SWITCH_A = power::Switches::PDU1_CH7_ACS_A_SIDE_3V3; + static constexpr power::Switches SWITCH_B = power::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; AcsBoardHelper helper; GpioIF* gpioIF = nullptr; diff --git a/mission/system/objects/DualLaneAssemblyBase.cpp b/mission/system/objects/DualLaneAssemblyBase.cpp index a55553a0..b3c37961 100644 --- a/mission/system/objects/DualLaneAssemblyBase.cpp +++ b/mission/system/objects/DualLaneAssemblyBase.cpp @@ -5,7 +5,7 @@ #include "OBSWConfig.h" DualLaneAssemblyBase::DualLaneAssemblyBase(object_id_t objectId, PowerSwitchIF* pwrSwitcher, - pcdu::Switches switch1, pcdu::Switches switch2, + power::Switches switch1, power::Switches switch2, Event pwrTimeoutEvent, Event sideSwitchNotAllowedEvent, Event transitionOtherSideFailedEvent) : AssemblyBase(objectId, 20), diff --git a/mission/system/objects/DualLaneAssemblyBase.h b/mission/system/objects/DualLaneAssemblyBase.h index a8a2f521..991c6bb2 100644 --- a/mission/system/objects/DualLaneAssemblyBase.h +++ b/mission/system/objects/DualLaneAssemblyBase.h @@ -18,8 +18,8 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF { static constexpr UniqueEventId_t POWER_STATE_MACHINE_TIMEOUT_ID = 2; static constexpr UniqueEventId_t SIDE_SWITCH_TRANSITION_NOT_ALLOWED_ID = 3; - DualLaneAssemblyBase(object_id_t objectId, PowerSwitchIF* pwrSwitcher, pcdu::Switches switch1, - pcdu::Switches switch2, Event pwrSwitchTimeoutEvent, + DualLaneAssemblyBase(object_id_t objectId, PowerSwitchIF* pwrSwitcher, power::Switches switch1, + power::Switches switch2, Event pwrSwitchTimeoutEvent, Event sideSwitchNotAllowedEvent, Event transitionOtherSideFailedEvent); protected: diff --git a/mission/system/objects/Stack5VHandler.h b/mission/system/objects/Stack5VHandler.h index 364d744b..f880afdf 100644 --- a/mission/system/objects/Stack5VHandler.h +++ b/mission/system/objects/Stack5VHandler.h @@ -32,7 +32,7 @@ class Stack5VHandler { HandlerState handlerState = HandlerState::IDLE; bool radSensorIsOn = false; bool plPcduIsOn = false; - pcdu::Switches stackSwitch = pcdu::Switches::P60_DOCK_5V_STACK; + power::Switches stackSwitch = power::Switches::P60_DOCK_5V_STACK; bool updateInternalStates(); }; diff --git a/mission/system/objects/SusAssembly.h b/mission/system/objects/SusAssembly.h index e993bee4..15f347dd 100644 --- a/mission/system/objects/SusAssembly.h +++ b/mission/system/objects/SusAssembly.h @@ -44,8 +44,8 @@ class SusAssembly : public DualLaneAssemblyBase { private: enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE; - static constexpr pcdu::Switches SWITCH_NOM = pcdu::Switches::PDU1_CH4_SUS_NOMINAL_3V3; - static constexpr pcdu::Switches SWITCH_RED = pcdu::Switches::PDU2_CH4_SUS_REDUNDANT_3V3; + static constexpr power::Switches SWITCH_NOM = power::Switches::PDU1_CH4_SUS_NOMINAL_3V3; + static constexpr power::Switches SWITCH_RED = power::Switches::PDU2_CH4_SUS_REDUNDANT_3V3; FixedArrayList modeTable; SusAssHelper helper; -- 2.43.0 From 3c6eb265c7d109d3a87b35b881d8de041ba6e4e8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 18:52:32 +0100 Subject: [PATCH 35/51] PLOC SUPV dummy has switch now --- dummies/PlocSupervisorDummy.cpp | 13 +++++++++++-- dummies/PlocSupervisorDummy.h | 7 ++++++- dummies/helpers.cpp | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp index c3eea5b0..b9b1948f 100644 --- a/dummies/PlocSupervisorDummy.cpp +++ b/dummies/PlocSupervisorDummy.cpp @@ -1,8 +1,10 @@ #include "PlocSupervisorDummy.h" PlocSupervisorDummy::PlocSupervisorDummy(object_id_t objectId, object_id_t comif, - CookieIF *comCookie) - : DeviceHandlerBase(objectId, comif, comCookie) {} + CookieIF *comCookie, PowerSwitchIF &pwrSwitcher) + : DeviceHandlerBase(objectId, comif, comCookie) { + setPowerSwitcher(&pwrSwitcher); +} PlocSupervisorDummy::~PlocSupervisorDummy() {} @@ -42,3 +44,10 @@ ReturnValue_t PlocSupervisorDummy::initializeLocalDataPool(localpool::DataPool & LocalDataPoolManager &poolManager) { return returnvalue::OK; } + +ReturnValue_t PlocSupervisorDummy::getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) { + *numberOfSwitches = 1; + *switches = reinterpret_cast(&switchId); + return returnvalue::OK; +} diff --git a/dummies/PlocSupervisorDummy.h b/dummies/PlocSupervisorDummy.h index 4118c893..963f1aa4 100644 --- a/dummies/PlocSupervisorDummy.h +++ b/dummies/PlocSupervisorDummy.h @@ -1,6 +1,7 @@ #pragma once #include +#include class PlocSupervisorDummy : public DeviceHandlerBase { public: @@ -10,10 +11,13 @@ class PlocSupervisorDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - PlocSupervisorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + PlocSupervisorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, + PowerSwitchIF &pwrSwitcher); virtual ~PlocSupervisorDummy(); protected: + const power::Switches switchId = power::Switches::PDU1_CH6_PLOC_12V; + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; @@ -27,4 +31,5 @@ class PlocSupervisorDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; }; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 026590e0..c4f8bce2 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -221,8 +221,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio auto* plocMpsocDummy = new PlocMpsocDummy(objects::PLOC_MPSOC_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); plocMpsocDummy->connectModeTreeParent(satsystem::payload::SUBSYSTEM); - auto* plocSupervisorDummy = new PlocSupervisorDummy(objects::PLOC_SUPERVISOR_HANDLER, - objects::DUMMY_COM_IF, comCookieDummy); + auto* plocSupervisorDummy = new PlocSupervisorDummy( + objects::PLOC_SUPERVISOR_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, pwrSwitcher); plocSupervisorDummy->connectModeTreeParent(satsystem::payload::SUBSYSTEM); } } -- 2.43.0 From f7be8ea63c633a614e15eaff5bb8085b1de059f5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 19:10:05 +0100 Subject: [PATCH 36/51] use supervisor fdir controls the power switch --- mission/controller/ThermalController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 36cb6e8a..1233a1eb 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1321,7 +1321,7 @@ void ThermalController::ctrlPlocMissionBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocMissionBoardLimits); - tooHotHandler(objects::PLOC_MPSOC_HANDLER, plocTooHotFlag); + tooHotHandler(objects::PLOC_SUPERVISOR_HANDLER, plocTooHotFlag); } void ThermalController::ctrlPlocProcessingBoard() { @@ -1335,7 +1335,7 @@ void ThermalController::ctrlPlocProcessingBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocProcessingBoardLimits); - tooHotHandler(objects::PLOC_MPSOC_HANDLER, plocTooHotFlag); + tooHotHandler(objects::PLOC_SUPERVISOR_HANDLER, plocTooHotFlag); } void ThermalController::ctrlDac() { -- 2.43.0 From eb468412376430d1836bfe414bd75eb038e5de35 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Mar 2023 17:40:11 +0100 Subject: [PATCH 37/51] update thermal controller --- unittest/controller/testThermalController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index d83980ee..d13d673c 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -21,7 +21,7 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, map0, map1); auto dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); - new CamSwitcher(objects::CAM_SWITCHER, *dummySwitcher, pcdu::Switches::PDU2_CH8_PAYLOAD_CAMERA); + new CamSwitcher(objects::CAM_SWITCHER, *dummySwitcher, power::Switches::PDU2_CH8_PAYLOAD_CAMERA); // TODO: Create dummy heater handler HeaterHandler* heaterHandler = nullptr; // new ThermalController(objects::THERMAL_CONTROLLER); -- 2.43.0 From 4871479ed54563172f65d508160a6b4fe8be4f41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 18 Mar 2023 11:17:24 +0100 Subject: [PATCH 38/51] fixes for q7s build --- bsp_q7s/core/ObjectFactory.cpp | 4 ++-- bsp_q7s/fmObjectFactory.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 99e53ba3..abd37678 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -645,7 +645,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit auto supvHelper = new PlocSupvUartManager(objects::PLOC_SUPERVISOR_HELPER); auto* supvHandler = new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), - pcdu::PDU1_CH6_PLOC_12V, *supvHelper); + power::PDU1_CH6_PLOC_12V, *supvHelper); supvHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ static_cast(consumer); @@ -722,7 +722,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, rws[idx] = rwHandler; } - createRwAssy(*pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); + createRwAssy(*pwrSwitcher, power::Switches::PDU2_CH2_RW_5V, rws, rwIds); #endif /* OBSW_ADD_RW == 1 */ } diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 5daab861..bb63a1d0 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -92,7 +92,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_SCEX_DEVICE == 1 createScexComponents(q7s::UART_SCEX_DEV, pwrSwitcher, *SdCardManager::instance(), false, - pcdu::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); + power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 -- 2.43.0 From ba9cf5d79d6ae59d35c0f08897c54e0093c51689 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sat, 18 Mar 2023 18:03:59 +0100 Subject: [PATCH 39/51] small changes --- mission/controller/ThermalController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 1233a1eb..c2b4bc4d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1028,7 +1028,7 @@ void ThermalController::ctrlMgt() { PoolReadGuard pg(&imtqThermalSet); auto heaterReq = static_cast(imtqThermalSet.heaterRequest.value); - + // TODO: remove heaterReq? if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { sensors[0].first = sensorTemperatures.mgt.isValid(); sensors[0].second = sensorTemperatures.mgt.value; @@ -1186,7 +1186,7 @@ void ThermalController::ctrlObc() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcLimits); if (componentAboveUpperLimit and not obcTooHotFlag) { - triggerEvent(tcsCtrl::OBC_OVERHEATING); + triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32()); obcTooHotFlag = true; } else if (not componentAboveUpperLimit) { obcTooHotFlag = false; @@ -1204,7 +1204,7 @@ void ThermalController::ctrlObcIfBoard() { numSensors = 3; ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, obcIfBoardLimits); if (componentAboveUpperLimit and not obcTooHotFlag) { - triggerEvent(tcsCtrl::OBC_OVERHEATING); + triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32()); obcTooHotFlag = true; } else if (not componentAboveUpperLimit) { obcTooHotFlag = false; -- 2.43.0 From 092e9fa508b0b1f841c4b1e4ed1d53d392b62df5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Mar 2023 14:18:32 +0100 Subject: [PATCH 40/51] bump deps --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 43fd0b2f..227524a2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 43fd0b2f59c3aeb2d3f4db10cfad56ee3709d68d +Subproject commit 227524a21da755d125bcb1a5ff67bcbc452f8cf9 diff --git a/tmtc b/tmtc index d3f9a83a..72963447 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d3f9a83af82cab66a557600752aaf361a4fcd035 +Subproject commit 7296344730f5140cb2d8f184200a8d6097874dfc -- 2.43.0 From b81618344e757a4d1026304ff5d33bfa86edbd7b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Mar 2023 14:38:10 +0100 Subject: [PATCH 41/51] update eive system FDIR --- mission/controller/ThermalController.cpp | 2 +- mission/system/objects/ComSubsystem.cpp | 3 +-- mission/system/objects/EiveSystem.cpp | 34 +++++++++++++----------- mission/system/objects/EiveSystem.h | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index c2b4bc4d..3c204427 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1028,7 +1028,7 @@ void ThermalController::ctrlMgt() { PoolReadGuard pg(&imtqThermalSet); auto heaterReq = static_cast(imtqThermalSet.heaterRequest.value); - // TODO: remove heaterReq? + // TODO: remove heaterReq? if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { sensors[0].first = sensorTemperatures.mgt.isValid(); sensors[0].second = sensorTemperatures.mgt.value; diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index c6a8cfc9..f2c4a821 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -23,6 +23,7 @@ ComSubsystem::ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequence } void ComSubsystem::performChildOperation() { + Subsystem::performChildOperation(); readEventQueue(); if (performRecoveryToRxOnly and not isInTransition) { startRxOnlyRecovery(true); @@ -37,8 +38,6 @@ void ComSubsystem::performChildOperation() { if (countdownActive) { checkTransmitterCountdown(); } - - Subsystem::performChildOperation(); } MessageQueueId_t ComSubsystem::getCommandQueue() const { return Subsystem::getCommandQueue(); } diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index 284beb49..df8ddfc3 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -7,6 +7,8 @@ #include #include +#include "mission/sysDefs.h" + EiveSystem::EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) : Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) { @@ -18,15 +20,15 @@ EiveSystem::EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, void EiveSystem::announceMode(bool recursive) { const char* modeStr = "UNKNOWN"; switch (mode) { - case (acs::AcsMode::OFF): { - modeStr = "OFF"; + case (satsystem::Mode::BOOT): { + modeStr = "OFF/BOOT"; break; } - case (acs::AcsMode::SAFE): { + case (satsystem::Mode::SAFE): { modeStr = "SAFE"; break; } - case (acs::AcsMode::PTG_IDLE): { + case (satsystem::Mode::PTG_IDLE): { modeStr = "POINTING IDLE"; break; } @@ -48,8 +50,12 @@ void EiveSystem::announceMode(bool recursive) { } void EiveSystem::performChildOperation() { + Subsystem::performChildOperation(); handleEventMessages(); - return Subsystem::performChildOperation(); + if (not isInTransition and performSafeRecovery) { + commandSelfToSafe(); + performSafeRecovery = false; + } } ReturnValue_t EiveSystem::initialize() { @@ -85,6 +91,11 @@ void EiveSystem::handleEventMessages() { switch (event.getEvent()) { case tcsCtrl::OBC_OVERHEATING: case tcsCtrl::PCDU_SYSTEM_OVERHEATING: { + if (isInTransition) { + performSafeRecovery = true; + return; + } + commandSelfToSafe(); break; } @@ -98,14 +109,5 @@ void EiveSystem::handleEventMessages() { } } } -void EiveSystem::commandSelfToSafe() { - if (fallbackCommandCd.hasTimedOut()) { - CommandMessage msg; - ModeMessage::setCmdModeMessage(msg, acs::AcsMode::SAFE, 0); - ReturnValue_t result = commandQueue->sendMessage(commandQueue->getId(), &msg); - if (result != returnvalue::OK) { - sif::error << "EiveSystem: Commanding EIVE-System to SAFE failed" << std::endl; - } - fallbackCommandCd.resetTimer(); - } -} + +void EiveSystem::commandSelfToSafe() { startTransition(satsystem::Mode::SAFE, 0); } diff --git a/mission/system/objects/EiveSystem.h b/mission/system/objects/EiveSystem.h index ab586e42..06110775 100644 --- a/mission/system/objects/EiveSystem.h +++ b/mission/system/objects/EiveSystem.h @@ -9,7 +9,7 @@ class EiveSystem : public Subsystem { private: MessageQueueIF* eventQueue = nullptr; - Countdown fallbackCommandCd = Countdown(30000); + bool performSafeRecovery = false; ReturnValue_t initialize() override; void performChildOperation() override; -- 2.43.0 From 0e5a3a2f6c5a9892eb1cd857bccda0c7556458ed Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Mar 2023 14:46:07 +0100 Subject: [PATCH 42/51] update changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eb71d92..7fc8f0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ will consitute of a breaking change warranting a new major release: to look into the reason of wrong outputs. To restore the reset ability, an action command has been added. - ## Fixed - Fixed transition for dual power lane assemblies: When going from dual side submode to single side @@ -35,7 +34,9 @@ will consitute of a breaking change warranting a new major release: Furthermore, the submode in the NORMAL mode now should be 0 instead of some ON mode submode. - Updated GYR bias values to newest measurements. This also corrects the ADIS values to always consit of just one digit. - +- EIVE system fallback and COM system fallback: Perform general subsystem handling first, then + event reception, and finally any new transition handling. + # [v1.38.0] 2023-03-17 eive-tmtc: v2.19.2 -- 2.43.0 From 2153294e6f75b165227845379f7bbbd7743e95e5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Mar 2023 15:17:31 +0100 Subject: [PATCH 43/51] EM build working now --- bsp_q7s/core/CoreController.cpp | 4 ++-- bsp_q7s/core/CoreController.h | 5 +++-- bsp_q7s/core/ObjectFactory.h | 2 +- bsp_q7s/em/emObjectFactory.cpp | 2 +- linux/devices/GpsHyperionLinuxController.cpp | 2 +- linux/devices/ImtqPollingTask.cpp | 9 ++++----- linux/devices/ImtqPollingTask.h | 3 ++- mission/system/objects/EiveSystem.cpp | 4 +--- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 61e7ee67..9d772a86 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -31,7 +31,7 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP; xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY; -CoreController::CoreController(object_id_t objectId, const std::atomic_uint16_t& i2cErrors) +CoreController::CoreController(object_id_t objectId, const std::atomic_uint16_t &i2cErrors) : ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), @@ -108,7 +108,7 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); - if(i2cErrors >= 5) { + if (i2cErrors >= 5) { bool protOpPerformed = false; triggerEvent(I2C_UNAVAILABLE_REBOOT); gracefulShutdownTasks(CURRENT_CHIP, CURRENT_COPY, protOpPerformed); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index cd504e3c..aaaba8ac 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "CoreDefinitions.h" @@ -15,7 +16,6 @@ #include "fsfw/controller/ExtendedControllerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" #include "mission/trace.h" -#include class Timer; class SdCardManager; @@ -132,7 +132,8 @@ class CoreController : public ExtendedControllerBase { //! P1: First 16 bits boot count of image 0 0, last 16 bits boot count of image 0 1. //! P2: First 16 bits boot count of image 1 0, last 16 bits boot count of image 1 1. static constexpr Event INDIVIDUAL_BOOT_COUNTS = event::makeEvent(SUBSYSTEM_ID, 8, severity::INFO); - static constexpr Event I2C_UNAVAILABLE_REBOOT = event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM); + static constexpr Event I2C_UNAVAILABLE_REBOOT = + event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM); CoreController(object_id_t objectId, const std::atomic_uint16_t& i2cErrors); virtual ~CoreController(); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 66ece5cd..68c64450 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include class LinuxLibgpioIF; class SerialComIF; diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index b82b0679..e3f1f0cf 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -66,7 +66,7 @@ void ObjectFactory::produce(void* args) { dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF); - new CoreController(objects::CORE_CONTROLLER); + new CoreController(objects::CORE_CONTROLLER, I2C_FATAL_ERRORS); // Regular FM code, does not work for EM if the hardware is not connected // createPcduComponents(gpioComIF, &pwrSwitcher); diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 8b26da5c..0b971f49 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -303,7 +303,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { bool timeValid = false; if (TIME_SET == (TIME_SET & gps.set)) { // To prevent totally incorrect times from being declared valid. - if(gpsSet.satInView.isValid() and gpsSet.satInView.value >= 1) { + if (gpsSet.satInView.isValid() and gpsSet.satInView.value >= 1) { timeValid = true; } timeval time = {}; diff --git a/linux/devices/ImtqPollingTask.cpp b/linux/devices/ImtqPollingTask.cpp index a0e59412..eccb0898 100644 --- a/linux/devices/ImtqPollingTask.cpp +++ b/linux/devices/ImtqPollingTask.cpp @@ -10,9 +10,8 @@ #include "fsfw/FSFW.h" -ImtqPollingTask::ImtqPollingTask(object_id_t imtqPollingTask, - std::atomic_uint16_t& i2cFatalErrors): SystemObject(imtqPollingTask), - i2cFatalErrors(i2cFatalErrors) { +ImtqPollingTask::ImtqPollingTask(object_id_t imtqPollingTask, std::atomic_uint16_t& i2cFatalErrors) + : SystemObject(imtqPollingTask), i2cFatalErrors(i2cFatalErrors) { semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); semaphore->acquire(); ipcLock = MutexFactory::instance()->createMutex(); @@ -429,7 +428,7 @@ ReturnValue_t ImtqPollingTask::performI2cFullRequest(uint8_t* reply, size_t repl if (ioctl(fd, I2C_SLAVE, i2cAddr) < 0) { sif::warning << "Opening IMTQ slave device failed with code " << errno << ": " << strerror(errno) << std::endl; - if(errno == EBUSY) { + if (errno == EBUSY) { i2cFatalErrors++; } } @@ -440,7 +439,7 @@ ReturnValue_t ImtqPollingTask::performI2cFullRequest(uint8_t* reply, size_t repl << ". Error description: " << strerror(errno) << std::endl; // This is a weird issue which sometimes occurs on debug builds. All I2C buses are busy // for all writes, - if(errno == EBUSY) { + if (errno == EBUSY) { i2cFatalErrors++; } return returnvalue::FAILED; diff --git a/linux/devices/ImtqPollingTask.h b/linux/devices/ImtqPollingTask.h index efe6a01b..592433c9 100644 --- a/linux/devices/ImtqPollingTask.h +++ b/linux/devices/ImtqPollingTask.h @@ -4,11 +4,12 @@ #include #include +#include + #include "fsfw/devicehandlers/DeviceCommunicationIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "mission/devices/devicedefinitions/imtqHelpers.h" -#include class ImtqPollingTask : public SystemObject, public ExecutableObjectIF, diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index df8ddfc3..55a649c0 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -102,9 +102,7 @@ void EiveSystem::handleEventMessages() { } break; default: - sif::debug << "AcsSubsystem::performChildOperation: Did not subscribe " - "to this event message" - << std::endl; + sif::debug << "EiveSystem: Did not subscribe to event " << event.getEvent() << std::endl; break; } } -- 2.43.0 From 0301c18af22e594412149007c1d520c041e9da0a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 24 Mar 2023 21:20:27 +0100 Subject: [PATCH 44/51] resolve some merge conflicts --- bsp_hosted/fsfwconfig/events/translateEvents.cpp | 3 ++- bsp_q7s/core/ObjectFactory.cpp | 9 ++------- bsp_q7s/em/emObjectFactory.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 3 ++- mission/controller/ThermalController.h | 3 +-- .../{controllerdefinitions/tcsCtrlDefs.h => tcsDefs.h} | 0 mission/powerDefs.h | 2 +- mission/system/com/ComSubsystem.cpp | 2 +- mission/system/objects/EiveSystem.cpp | 5 ++--- 9 files changed, 12 insertions(+), 17 deletions(-) rename mission/controller/{controllerdefinitions/tcsCtrlDefs.h => tcsDefs.h} (100%) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index caddc719..d9841d02 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -212,7 +212,8 @@ const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING = "SIDE_SWITCH_TRANSITION_ 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"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index feafe4c2..edc237a9 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -603,7 +603,7 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HANDLER); auto syrlinksHandler = new SyrlinksHandler(objects::SYRLINKS_HANDLER, objects::SYRLINKS_COM_HANDLER, - syrlinksUartCookie, pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); + syrlinksUartCookie, power::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); syrlinksHandler->setPowerSwitcher(pwrSwitcher); syrlinksHandler->connectModeTreeParent(*syrlinksAssy); #if OBSW_DEBUG_SYRLINKS == 1 @@ -956,13 +956,8 @@ void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { } auto strFdir = new StrFdir(objects::STAR_TRACKER); auto starTracker = -<<<<<<< HEAD - new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, - paramJsonFile, strHelper, power::PDU1_CH2_STAR_TRACKER_5V); -======= new StarTrackerHandler(objects::STAR_TRACKER, objects::STR_COM_IF, starTrackerCookie, - paramJsonFile, strComIF, pcdu::PDU1_CH2_STAR_TRACKER_5V); ->>>>>>> origin/develop + paramJsonFile, strComIF, power::PDU1_CH2_STAR_TRACKER_5V); starTracker->setPowerSwitcher(pwrSwitcher); starTracker->connectModeTreeParent(*strAssy); starTracker->setCustomFdir(strFdir); diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 1ebd3015..87237916 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -18,8 +18,8 @@ #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "linux/ObjectFactory.h" #include "linux/callbacks/gpioCallbacks.h" -#include "mission/system/com/comModeTree.h" #include "mission/core/GenericFactory.h" +#include "mission/system/com/comModeTree.h" void ObjectFactory::produce(void* args) { ObjectFactory::setStatics(); diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index caddc719..d9841d02 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -212,7 +212,8 @@ const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING = "SIDE_SWITCH_TRANSITION_ 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"; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index e7e42031..c97baaba 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -5,7 +5,6 @@ #include #include #include - #include #include #include @@ -13,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/mission/controller/controllerdefinitions/tcsCtrlDefs.h b/mission/controller/tcsDefs.h similarity index 100% rename from mission/controller/controllerdefinitions/tcsCtrlDefs.h rename to mission/controller/tcsDefs.h diff --git a/mission/powerDefs.h b/mission/powerDefs.h index c2649e37..0444823c 100644 --- a/mission/powerDefs.h +++ b/mission/powerDefs.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace power { diff --git a/mission/system/com/ComSubsystem.cpp b/mission/system/com/ComSubsystem.cpp index 1bb38f51..5001dbe5 100644 --- a/mission/system/com/ComSubsystem.cpp +++ b/mission/system/com/ComSubsystem.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include diff --git a/mission/system/objects/EiveSystem.cpp b/mission/system/objects/EiveSystem.cpp index 09096b16..f6b99b1e 100644 --- a/mission/system/objects/EiveSystem.cpp +++ b/mission/system/objects/EiveSystem.cpp @@ -3,10 +3,9 @@ #include #include #include - #include -#include -#include +#include +#include #include "mission/sysDefs.h" -- 2.43.0 From 5c97020087f91964f6655deb0f59e0076eb2ce3e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 28 Mar 2023 15:11:21 +0200 Subject: [PATCH 45/51] small change --- .idea/cmake.xml | 1 - mission/controller/ThermalController.cpp | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.idea/cmake.xml b/.idea/cmake.xml index f890b357..3be3a2b0 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -10,7 +10,6 @@ - \ No newline at end of file diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 21a2afb3..bfed0ad2 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -933,7 +933,6 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { - // TODO: check heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; @@ -957,7 +956,7 @@ void ThermalController::ctrlAcsBoard() { resetSensorsArray(); return; } - + resetSensorsArray(); // B side sensors[0].first = deviceTemperatures.gyro2SideB.isValid(); sensors[0].second = deviceTemperatures.gyro2SideB.value; @@ -976,8 +975,6 @@ void ThermalController::ctrlAcsBoard() { if (chooseHeater(switchNr, redSwitchNr)) { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater" - << static_cast(thermalComponent) << " OFF" << std::endl; } } } @@ -1213,7 +1210,7 @@ void ThermalController::ctrlPcduAcu() { if (chooseHeater(switchNr, redSwitchNr)) { bool sensorTempAvailable = true; - + //TODO: check if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { @@ -1458,9 +1455,6 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, redSwitchNr)) { // TODO: muss der Heater dann wirklich abgeschalten werden? if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater" - << static_cast(thermalComponent) << " OFF" - << std::endl; // TODO: printouts löschen } } } -- 2.43.0 From 36d7852c1d86c0f8dd9aaa3ddacb6402bed5d052 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 28 Mar 2023 16:35:49 +0200 Subject: [PATCH 46/51] changes --- mission/controller/ThermalController.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index bfed0ad2..759f1163 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -137,8 +137,8 @@ void ThermalController::performControlOperation() { } } - std::array heaterStates; - heaterHandler.getAllSwitchStates(heaterStates); + std::array heaterSwitchStateArray{}; + heaterHandler.getAllSwitchStates(heaterSwitchStateArray); { PoolReadGuard pg(&heaterInfo); std::memcpy(heaterInfo.heaterSwitchState.value, heaterStates.data(), 8); @@ -150,7 +150,9 @@ void ThermalController::performControlOperation() { } } - performThermalModuleCtrl(); + if(mode != MODE_OFF) { + performThermalModuleCtrl(); + } cycles++; } @@ -983,11 +985,6 @@ void ThermalController::ctrlAcsBoard() { void ThermalController::ctrlMgt() { thermalComponent = MGT; - PoolReadGuard pg(&imtqThermalSet); - auto heaterReq = - static_cast(imtqThermalSet.heaterRequest.value); - // TODO: remove heaterReq? - if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { sensors[0].first = sensorTemperatures.mgt.isValid(); sensors[0].second = sensorTemperatures.mgt.value; sensors[1].first = deviceTemperatures.mgt.isValid(); @@ -996,7 +993,7 @@ void ThermalController::ctrlMgt() { sensors[2].second = sensorTemperatures.plpcduHeatspreader.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, mgtLimits); - } + } void ThermalController::ctrlRw() { -- 2.43.0 From 520b41c53b2575f1bb679c105923dd6be941887f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Mar 2023 17:21:43 +0200 Subject: [PATCH 47/51] transition basic mode handling --- mission/controller/ThermalController.cpp | 48 ++++++++++++++++++------ mission/controller/ThermalController.h | 5 +++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 301470cb..38c32d3b 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -150,7 +150,14 @@ void ThermalController::performControlOperation() { } } - if(mode != MODE_OFF) { + if (transitionToOff) { + for (const auto& switchState : heaterSwitchStateArray) { + if (switchState != HeaterHandler::SwitchState::OFF) { + return; + } + setMode(MODE_OFF); + } + } else if (mode != MODE_OFF) { performThermalModuleCtrl(); } cycles++; @@ -990,15 +997,14 @@ void ThermalController::ctrlAcsBoard() { void ThermalController::ctrlMgt() { thermalComponent = MGT; - sensors[0].first = sensorTemperatures.mgt.isValid(); - sensors[0].second = sensorTemperatures.mgt.value; - sensors[1].first = deviceTemperatures.mgt.isValid(); - sensors[1].second = deviceTemperatures.mgt.value; - 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); - + sensors[0].first = sensorTemperatures.mgt.isValid(); + sensors[0].second = sensorTemperatures.mgt.value; + sensors[1].first = deviceTemperatures.mgt.isValid(); + sensors[1].second = deviceTemperatures.mgt.value; + 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); } void ThermalController::ctrlRw() { @@ -1212,7 +1218,7 @@ void ThermalController::ctrlPcduAcu() { if (chooseHeater(switchNr, redSwitchNr)) { bool sensorTempAvailable = true; - //TODO: check + // TODO: check if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { @@ -1599,6 +1605,13 @@ uint32_t ThermalController::tempFloatToU32() const { return tempRaw; } +void ThermalController::setMode(Mode_t mode) { + this->mode = mode; + modeHelper.modeChanged(mode, submode); + modeChanged(mode, submode); + announceMode(false); +} + void ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { if (componentAboveUpperLimit and not oneShotFlag) { EventManagerIF::triggerEvent(object, overHeatEventToTrigger, tempFloatToU32()); @@ -1607,3 +1620,16 @@ void ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { oneShotFlag = false; } } + +void ThermalController::startTransition(Mode_t mode_, Submode_t submode_) { + triggerEvent(CHANGING_MODE, mode, submode); + if (mode == MODE_OFF) { + for (uint8_t i; i < heater::Switchers::NUMBER_OF_SWITCHES; i++) { + heaterHandler.switchHeater(static_cast(i), + HeaterHandler::SwitchState::OFF); + } + transitionToOff = true; + } else { + setMode(mode_); + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 4fe38c4e..d2e1954d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -243,6 +243,8 @@ class ThermalController : public ExtendedControllerBase { bool obcTooHotFlag = false; bool strTooHotFlag = false; bool rwTooHotFlag = false; + + bool transitionToOff = false; uint32_t cycles = 0; std::array thermalStates{}; std::array heaterStates{}; @@ -268,6 +270,8 @@ class ThermalController : public ExtendedControllerBase { static constexpr dur_millis_t MUTEX_TIMEOUT = 50; + void startTransition(Mode_t mode, Submode_t submode) override; + void resetSensorsArray(); void copySensors(); void copySus(); @@ -304,6 +308,7 @@ class ThermalController : public ExtendedControllerBase { void ctrlMpa(); void ctrlScexBoard(); void heaterTransitionControl(); + void setMode(Mode_t mode); uint32_t tempFloatToU32() const; void tooHotHandler(object_id_t object, bool& oneShotFlag); }; -- 2.43.0 From def7eca2f26a0f2d2425453f2cd87831ae3b2de6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Mar 2023 19:38:02 +0200 Subject: [PATCH 48/51] cleaning up a bit --- bsp_q7s/core/ObjectFactory.cpp | 2 +- fsfw | 2 +- mission/controller/ThermalController.cpp | 189 +++++++++++++++++------ mission/controller/ThermalController.h | 18 ++- mission/controller/tcsDefs.h | 1 + 5 files changed, 156 insertions(+), 56 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 9c42be86..bbfa4c8a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -971,7 +971,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enable new ImtqPollingTask(objects::IMTQ_POLLING, I2C_FATAL_ERRORS); I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, q7s::I2C_PL_EIVE); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::IMTQ_POLLING, imtqI2cCookie, - pcdu::Switches::PDU1_CH3_MGT_5V, enableHkSets); + power::Switches::PDU1_CH3_MGT_5V, enableHkSets); imtqHandler->enableThermalModule(ThermalStateCfg()); imtqHandler->setPowerSwitcher(pwrSwitcher); imtqHandler->connectModeTreeParent(*imtqAssy); diff --git a/fsfw b/fsfw index 314f0fa2..4f632e2c 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 314f0fa2cde749ee1021d311e222bb0044cc2e5b +Subproject commit 4f632e2c6866cee88dd9920a965aa0d079799aa3 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 38c32d3b..abf20bb8 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -18,7 +18,7 @@ // Enabling this should trigger a special event which in turn should trigger a system reaction. #define LOWER_SYRLINKS_UPPER_LIMITS 0 -#define LOWER_EBAND_UPPER_LIMITS 0 +#define LOWER_EBAND_UPPER_LIMITS 1 #define LOWER_PLOC_UPPER_LIMITS 0 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) @@ -110,11 +110,21 @@ void ThermalController::performControlOperation() { } if (cycles == 50) { - sif::debug << "ThermalController: changing limits" << std::endl; + sif::debug << "ThermalController: changing limits" << std::endl; // TODO: rausschmeissen #if LOWER_SYRLINKS_UPPER_LIMITS == 1 sBandTransceiverLimits.cutOffLimit = 0; sBandTransceiverLimits.opUpperLimit = 0; sBandTransceiverLimits.nopUpperLimit = 0; +#endif +#if LOWER_PLOC_UPPER_LIMITS == 1 + plocMissionBoardLimits.cutOffLimit = 0; + plocMissionBoardLimits.opUpperLimit = 0; + plocMissionBoardLimits.nopUpperLimit = 0; +#endif +#if LOWER_EBAND_UPPER_LIMITS == 1 + hpaLimits.cutOffLimit = 0; + hpaLimits.opUpperLimit = 0; + hpaLimits.nopUpperLimit = 0; #endif } @@ -137,7 +147,7 @@ void ThermalController::performControlOperation() { } } - std::array heaterSwitchStateArray{}; + HeaterSwitchStates heaterSwitchStateArray{}; heaterHandler.getAllSwitchStates(heaterSwitchStateArray); { PoolReadGuard pg(&heaterInfo); @@ -153,12 +163,21 @@ void ThermalController::performControlOperation() { if (transitionToOff) { for (const auto& switchState : heaterSwitchStateArray) { if (switchState != HeaterHandler::SwitchState::OFF) { + transitionToOffCycles++; + // if heater still ON after 10 cycles, switch OFF again + if (transitionToOffCycles == 10) { + for (uint8_t i; i < heater::Switchers::NUMBER_OF_SWITCHES; i++) { + heaterHandler.switchHeater(static_cast(i), + HeaterHandler::SwitchState::OFF); + } + triggerEvent(tcsCtrl::HEATER_NOT_OFF_FOR_OFF_MODE); + } return; } setMode(MODE_OFF); } } else if (mode != MODE_OFF) { - performThermalModuleCtrl(); + performThermalModuleCtrl(heaterSwitchStateArray); } cycles++; } @@ -1005,6 +1024,7 @@ void ThermalController::ctrlMgt() { sensors[2].second = sensorTemperatures.plpcduHeatspreader.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, mgtLimits); + // TODO: trigger special event } void ThermalController::ctrlRw() { @@ -1112,7 +1132,7 @@ void ThermalController::ctrlStr() { sensors[2].second = sensorTemperatures.dro.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits); - tooHotHandler(objects::STAR_TRACKER, strTooHotFlag); + tooHotHandlerWhichClearsOneShotFlag(objects::STAR_TRACKER, strTooHotFlag); } void ThermalController::ctrlIfBoard() { @@ -1173,7 +1193,7 @@ void ThermalController::ctrlObcIfBoard() { triggerEvent(tcsCtrl::OBC_OVERHEATING, tempFloatToU32()); obcTooHotFlag = true; } else if (not componentAboveUpperLimit) { - obcTooHotFlag = false; + obcTooHotFlag = false; // TODO: !! } } @@ -1208,7 +1228,7 @@ void ThermalController::ctrlPcduP60Board() { pcduSystemTooHotFlag = true; } else if (not componentAboveUpperLimit) { pcduSystemTooHotFlag = false; - } + } // TODO: ! } void ThermalController::ctrlPcduAcu() { @@ -1417,10 +1437,10 @@ void ThermalController::ctrlScexBoard() { sensors[2].second = sensorTemperatures.hpa.value; numSensors = 3; ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, scexBoardLimits); - tooHotHandler(objects::SCEX, scexTooHotFlag); + tooHotHandlerWhichClearsOneShotFlag(objects::SCEX, scexTooHotFlag); } -void ThermalController::performThermalModuleCtrl() { +void ThermalController::performThermalModuleCtrl(const HeaterSwitchStates& heaterSwitchStates) { ctrlAcsBoard(); ctrlMgt(); ctrlRw(); @@ -1435,21 +1455,56 @@ void ThermalController::performThermalModuleCtrl() { ctrlPcduPdu(); // Payload components + std::array plocInAllowedRange{}; ctrlPlocMissionBoard(); + plocInAllowedRange.at(0) = not componentAboveUpperLimit; ctrlPlocProcessingBoard(); + plocInAllowedRange.at(1) = not componentAboveUpperLimit; + + if (plocTooHotFlag) { + bool clearFlag = true; + for (const auto& inRange : plocInAllowedRange) { + if (not inRange) { + clearFlag = false; + } + } + if (clearFlag) { + plocTooHotFlag = false; + } + } ctrlCameraBody(); ctrlScexBoard(); // E-Band + std::array eBandInAllowedRange{}; ctrlPlPcduBoard(); + eBandInAllowedRange.at(0) = not componentAboveUpperLimit; ctrlDac(); + eBandInAllowedRange.at(1) = not componentAboveUpperLimit; ctrlDro(); + eBandInAllowedRange.at(2) = not componentAboveUpperLimit; ctrlX8(); + eBandInAllowedRange.at(3) = not componentAboveUpperLimit; ctrlHpa(); + eBandInAllowedRange.at(4) = not componentAboveUpperLimit; ctrlTx(); + eBandInAllowedRange.at(5) = not componentAboveUpperLimit; ctrlMpa(); + eBandInAllowedRange.at(6) = not componentAboveUpperLimit; - heaterTransitionControl(); + if (eBandTooHotFlag) { + bool clearFlag = true; + for (const auto& inRange : eBandInAllowedRange) { + if (not inRange) { + clearFlag = false; + } + } + if (clearFlag) { + eBandTooHotFlag = false; + } + } + + heaterTransitionControl(heaterSwitchStates); } void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, @@ -1506,39 +1561,32 @@ 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(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::checkLimitsAndCtrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, const TempLimits& tempLimit) { componentAboveCutOffLimit = false; componentAboveUpperLimit = false; - auto tempTooHighHandler = [&](const char* whatLimit, bool heaterIsOn) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::checkLimitsAndCtrlHeater: Exceeded " << whatLimit - << ": " - "Heater for component " - << static_cast(thermalComponent) << 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) { + // 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); + } else { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { // TODO: check NOP limit and maybe trigger fdir @@ -1548,10 +1596,11 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, << static_cast(thermalComponent) << " ON" << std::endl; heaterStates[switchNr].switchTransition = true; thermalStates[thermalComponent].heating = true; + heaterStates[switchNr].target = HeaterHandler::SwitchState::ON; } else { thermalStates[thermalComponent].heating = false; } - checkUpperLimits(false); + heaterCtrlCheckUpperLimits(switchNr, redSwitchNr, true, tempLimit); // Heater on } else if (heaterHandler.checkSwitchState(switchNr)) { if (thermalStates[thermalComponent].heating) { @@ -1561,22 +1610,47 @@ void ThermalController::checkLimitsAndCtrlHeater(heater::Switchers switchNr, sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " << static_cast(thermalComponent) << " OFF" << std::endl; heaterStates[switchNr].switchTransition = true; + heaterStates[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 = checkUpperLimits(true); + bool tooHighHandlerAlreadyCalled = + heaterCtrlCheckUpperLimits(switchNr, redSwitchNr, true, tempLimit); if (sensorTemp >= tempLimit.cutOffLimit) { componentAboveCutOffLimit = true; if (not tooHighHandlerAlreadyCalled) { - tempTooHighHandler("CutOff-Limit", true); + heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "CutOff-Limit"); } } } } } } + +bool ThermalController::heaterCtrlCheckUpperLimits(heater::Switchers switchNr, + heater::Switchers redSwitchNr, + bool doHeaterHandling, + const TempLimits& tempLimit) { + if (sensorTemp >= tempLimit.nopUpperLimit) { + componentAboveUpperLimit = true; + if (doHeaterHandling) { + heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "NOP-Limit"); + } + overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH; + return true; + } else if (sensorTemp >= tempLimit.opUpperLimit) { + componentAboveUpperLimit = true; + if (doHeaterHandling) { + heaterCtrlTempTooHighHandler(switchNr, redSwitchNr, "OP-Limit"); + } + overHeatEventToTrigger = ThermalComponentIF::COMPONENT_TEMP_HIGH; + return true; + } + return false; +} + void ThermalController::resetSensorsArray() { for (auto& validValuePair : sensors) { validValuePair.first = false; @@ -1584,15 +1658,19 @@ void ThermalController::resetSensorsArray() { } thermalComponent = NONE; } -void ThermalController::heaterTransitionControl() { +void ThermalController::heaterTransitionControl(const HeaterSwitchStates& currentHeaterStates) { // TODO: Test for (unsigned i = 0; i < 7; i++) { if (heaterStates[i].switchTransition) { - if (heaterStates[i].heaterSwitchControlErrorCounter > 3) { + if (currentHeaterStates[i] == heaterStates[i].target) { heaterStates[i].switchTransition = false; - heaterStates[i].heaterSwitchControlErrorCounter = 0; + continue; } - heaterStates[i].heaterSwitchControlErrorCounter++; + if (heaterStates[i].heaterSwitchControlCycles > 3) { + heaterStates[i].switchTransition = false; + heaterStates[i].heaterSwitchControlCycles = 0; + } + heaterStates[i].heaterSwitchControlCycles++; } } } @@ -1606,29 +1684,40 @@ uint32_t ThermalController::tempFloatToU32() const { } void ThermalController::setMode(Mode_t mode) { + if (mode == MODE_OFF) { + transitionToOff = false; + } this->mode = mode; modeHelper.modeChanged(mode, submode); - modeChanged(mode, submode); announceMode(false); } -void ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { +bool ThermalController::tooHotHandler(object_id_t object, bool& oneShotFlag) { if (componentAboveUpperLimit and not oneShotFlag) { + // Too hot -> returns true EventManagerIF::triggerEvent(object, overHeatEventToTrigger, tempFloatToU32()); oneShotFlag = true; - } else if (not componentAboveUpperLimit) { + return true; + } + return false; +} + +void ThermalController::tooHotHandlerWhichClearsOneShotFlag(object_id_t object, bool& oneShotFlag) { + // Clear the one shot flag is the component is in acceptable temperature range. + if (not tooHotHandler(object, oneShotFlag) and not componentAboveUpperLimit) { oneShotFlag = false; } } void ThermalController::startTransition(Mode_t mode_, Submode_t submode_) { - triggerEvent(CHANGING_MODE, mode, submode); - if (mode == MODE_OFF) { + triggerEvent(CHANGING_MODE, mode_, submode_); + if (mode_ == MODE_OFF) { for (uint8_t i; i < heater::Switchers::NUMBER_OF_SWITCHES; i++) { heaterHandler.switchHeater(static_cast(i), HeaterHandler::SwitchState::OFF); } transitionToOff = true; + transitionToOffCycles = 0; } else { setMode(mode_); } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index d2e1954d..37ed9d87 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -53,9 +53,12 @@ struct ThermalState { struct HeaterState { bool switchTransition; - uint8_t heaterSwitchControlErrorCounter; + HeaterHandler::SwitchState target; + uint8_t heaterSwitchControlCycles; }; +using HeaterSwitchStates = std::array; + enum ThermalComponents : uint8_t { NONE = 0, ACS_BOARD = 1, @@ -94,7 +97,7 @@ class ThermalController : public ExtendedControllerBase { ReturnValue_t initialize() override; protected: - void performThermalModuleCtrl(); + void performThermalModuleCtrl(const HeaterSwitchStates& heaterSwitchStates); ReturnValue_t handleCommandMessage(CommandMessage* message) override; void performControlOperation() override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -245,6 +248,7 @@ class ThermalController : public ExtendedControllerBase { bool rwTooHotFlag = false; bool transitionToOff = false; + uint32_t transitionToOffCycles = 0; uint32_t cycles = 0; std::array thermalStates{}; std::array heaterStates{}; @@ -281,6 +285,11 @@ class ThermalController : public ExtendedControllerBase { 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); + bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); bool selectAndReadSensorTemp(); @@ -307,10 +316,11 @@ class ThermalController : public ExtendedControllerBase { void ctrlTx(); void ctrlMpa(); void ctrlScexBoard(); - void heaterTransitionControl(); + void heaterTransitionControl(const HeaterSwitchStates& currentHeaterStates); void setMode(Mode_t mode); uint32_t tempFloatToU32() const; - void tooHotHandler(object_id_t object, bool& oneShotFlag); + bool tooHotHandler(object_id_t object, bool& oneShotFlag); + void tooHotHandlerWhichClearsOneShotFlag(object_id_t object, bool& oneShotFlag); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/controller/tcsDefs.h b/mission/controller/tcsDefs.h index 321a9c71..e187091b 100644 --- a/mission/controller/tcsDefs.h +++ b/mission/controller/tcsDefs.h @@ -16,6 +16,7 @@ static constexpr Event SYRLINKS_OVERHEATING = MAKE_EVENT(2, severity::HIGH); static constexpr Event OBC_OVERHEATING = MAKE_EVENT(4, severity::HIGH); static constexpr Event CAMERA_OVERHEATING = MAKE_EVENT(5, severity::HIGH); static constexpr Event PCDU_SYSTEM_OVERHEATING = MAKE_EVENT(6, severity::HIGH); +static constexpr Event HEATER_NOT_OFF_FOR_OFF_MODE = MAKE_EVENT(7, severity::MEDIUM); enum SetId : uint32_t { SENSOR_TEMPERATURES = 0, -- 2.43.0 From e9c5bfe324d19b86428931f54febd3b00a86d630 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Apr 2023 14:09:54 +0200 Subject: [PATCH 49/51] event spam has stopped --- .../fsfwconfig/events/translateEvents.cpp | 6 +- linux/fsfwconfig/events/translateEvents.cpp | 6 +- mission/controller/ThermalController.cpp | 235 ++++++++++-------- mission/controller/ThermalController.h | 24 +- mission/tcs/HeaterHandler.cpp | 8 +- mission/tcs/HeaterHandler.h | 2 +- 6 files changed, 162 insertions(+), 119 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 3e1dd369..a070245a 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -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"; diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 3e1dd369..a070245a 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -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"; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index abf20bb8..021ad982 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -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,11 +1047,14 @@ 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); - sensorTemps[0] = tempFloatToU32(); - if (componentAboveUpperLimit) { - oneIsAboveLimit = true; - eventToTrigger = overHeatEventToTrigger; + { + HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + ctrlComponentTemperature(htrCtx); + sensorTemps[0] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + eventToTrigger = overHeatEventToTrigger; + } } // RW2 @@ -1062,15 +1068,17 @@ 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); - sensorTemps[1] = tempFloatToU32(); - if (componentAboveUpperLimit) { - oneIsAboveLimit = true; - if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { - eventToTrigger = overHeatEventToTrigger; + { + HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + ctrlComponentTemperature(htrCtx); + sensorTemps[1] = tempFloatToU32(); + if (componentAboveUpperLimit) { + oneIsAboveLimit = true; + if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { + eventToTrigger = overHeatEventToTrigger; + } } } - // RW3 thermalComponent = RW; sensors[0].first = deviceTemperatures.rw3.isValid(); @@ -1082,12 +1090,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); - sensorTemps[2] = tempFloatToU32(); - if (componentAboveUpperLimit) { - oneIsAboveLimit = true; - if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { - eventToTrigger = overHeatEventToTrigger; + { + HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + ctrlComponentTemperature(htrCtx); + sensorTemps[2] = tempFloatToU32(); + if (componentAboveUpperLimit) { + 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].second = sensorTemperatures.dro.value; numSensors = 4; - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); - sensorTemps[3] = tempFloatToU32(); - if (componentAboveUpperLimit) { - oneIsAboveLimit = true; - if (eventToTrigger != ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH) { - eventToTrigger = overHeatEventToTrigger; + { + HeaterContext htrCtx(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + ctrlComponentTemperature(htrCtx); + sensorTemps[3] = tempFloatToU32(); + if (componentAboveUpperLimit) { + 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].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, - plocMissionBoardLimits); + 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, - plocProcessingBoardLimits); + 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(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(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)) { - // TODO: check NOP limit and maybe trigger fdir - if (sensorTemp < tempLimit.opLowerLimit) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); + 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 < htrCtx.tempLimit.opLowerLimit) { + heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " << static_cast(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(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; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 37ed9d87..0ceb9cae 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -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(); diff --git a/mission/tcs/HeaterHandler.cpp b/mission/tcs/HeaterHandler.cpp index 1c693882..c6a3a121 100644 --- a/mission/tcs/HeaterHandler.cpp +++ b/mission/tcs/HeaterHandler.cpp @@ -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(switchNr)) == SwitchState::ON) { + if (getSwitchState(static_cast(switchNr)) == SwitchState::ON) { return PowerSwitchIF::SWITCH_ON; } return PowerSwitchIF::SWITCH_OFF; diff --git a/mission/tcs/HeaterHandler.h b/mission/tcs/HeaterHandler.h index 05e7e5d8..6787b660 100644 --- a/mission/tcs/HeaterHandler.h +++ b/mission/tcs/HeaterHandler.h @@ -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. -- 2.43.0 From f4b47a24c0964a5dcfc04539d3bc7b34e65a3a8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Apr 2023 14:22:58 +0200 Subject: [PATCH 50/51] adaptions for EM build --- CMakeLists.txt | 2 +- bsp_q7s/em/emObjectFactory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29da10da..ed144b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ set(OBSW_ADD_TCS_CTRL 1 CACHE STRING "Add TCS controllers") set(OBSW_ADD_HEATERS - ${INIT_VAL} + 1 CACHE STRING "Add TCS heaters") set(OBSW_ADD_PLOC_SUPERVISOR ${INIT_VAL} diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 1f873b99..ad520441 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -137,8 +137,8 @@ void ObjectFactory::produce(void* args) { pcdu::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif createAcsController(true, enableHkSets); - HeaterHandler* heaterHandler = nullptr; - ObjectFactory::createGenericHeaterComponents(*gpioComIF, *pwrSwitcher, heaterHandler); + HeaterHandler* heaterHandler; + createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler); satsystem::init(); } -- 2.43.0 From a8a0299b462f643ae3af458cfcf969ceb6bd7e7b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Apr 2023 14:38:00 +0200 Subject: [PATCH 51/51] some adaptions, heater to off seems to work --- fsfw | 2 +- mission/controller/ThermalController.cpp | 4 ---- mission/tcs/HeaterHandler.cpp | 3 ++- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fsfw b/fsfw index 4f632e2c..e2e87b14 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 4f632e2c6866cee88dd9920a965aa0d079799aa3 +Subproject commit e2e87b149d91c51196c76d6b84243fce1c77a28a diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 021ad982..9ab16cf2 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1615,15 +1615,12 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { // still check whether components are out of range, which might be important information for the // top level control loop. if (heaterStates[htrCtx.switchNr].switchTransition) { - sif::debug << " heater in switch transition" << std::endl; htrCtx.doHeaterHandling = false; heaterCtrlCheckUpperLimits(htrCtx); } else { // Heater off 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 < htrCtx.tempLimit.opLowerLimit) { heaterHandler.switchHeater(htrCtx.switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::checkLimitsAndCtrlHeater: Heater " @@ -1637,7 +1634,6 @@ void ThermalController::checkLimitsAndCtrlHeater(HeaterContext& htrCtx) { heaterCtrlCheckUpperLimits(htrCtx); // Heater on } 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 >= htrCtx.tempLimit.opLowerLimit + TEMP_OFFSET) { diff --git a/mission/tcs/HeaterHandler.cpp b/mission/tcs/HeaterHandler.cpp index c6a3a121..529fe698 100644 --- a/mission/tcs/HeaterHandler.cpp +++ b/mission/tcs/HeaterHandler.cpp @@ -292,7 +292,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF && heater.waitMainSwitchOn) { // Just waiting for the main switch being set on return; - } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF or + mainSwitchState == PowerSwitchIF::SWITCH_UNKNOWN) { mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); heater.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); heater.waitMainSwitchOn = true; -- 2.43.0