From 311d03e6800baa0fef86c14ccd467875a7b8e477 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 16 Nov 2022 16:36:59 +0100 Subject: [PATCH 01/59] basic changes for heater handler --- mission/devices/HeaterHandler.cpp | 4 ++++ mission/devices/HeaterHandler.h | 3 +++ tmtc | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 3c25eb6a..17bdf640 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -321,6 +321,10 @@ HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers swi return heaterVec.at(switchNr).switchState; } +ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, ReturnValue_t onOff) { + return sendSwitchCommand(heater, onOff); +} + bool HeaterHandler::allSwitchesOff() { bool allSwitchesOrd = false; MutexGuard mg(heaterMutex); diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index b63f4dfe..dce6454a 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -40,6 +40,7 @@ class HeaterHandler : public ExecutableObjectIF, public PowerSwitchIF, public SystemObject, public HasActionsIF { + friend class ThermalController; public: static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; @@ -59,6 +60,8 @@ class HeaterHandler : public ExecutableObjectIF, virtual ~HeaterHandler(); +protected: + ReturnValue_t switchHeater(heater::Switchers heater, ReturnValue_t onOff); ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; diff --git a/tmtc b/tmtc index 66a1362e..d5813e1a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 66a1362e7e977e427a66fd3176a9e7b6bc1b5998 +Subproject commit d5813e1a422beae7d0cb092a885e0956e9f1ddc1 From 33bd5cb63a276dad101c53af730c49120f07616f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 16 Nov 2022 17:33:19 +0100 Subject: [PATCH 02/59] this is going to be annoying --- dummies/TemperatureSensorsDummy.cpp | 28 +++++++++++-------- dummies/TemperatureSensorsDummy.h | 3 +- mission/controller/ThermalController.cpp | 2 ++ mission/controller/ThermalController.h | 8 ++++++ .../ThermalControllerDefinitions.h | 7 +++-- mission/devices/HeaterHandler.cpp | 2 +- mission/devices/HeaterHandler.h | 5 ++-- 7 files changed, 36 insertions(+), 19 deletions(-) diff --git a/dummies/TemperatureSensorsDummy.cpp b/dummies/TemperatureSensorsDummy.cpp index 52190ee8..ccf3f0a7 100644 --- a/dummies/TemperatureSensorsDummy.cpp +++ b/dummies/TemperatureSensorsDummy.cpp @@ -7,7 +7,8 @@ TemperatureSensorsDummy::TemperatureSensorsDummy() : ExtendedControllerBase(objects::RTD_0_IC3_PLOC_HEATSPREADER), - max31865Set(this, MAX31865::MAX31865_SET_ID) { + max31865PlocHeatspreaderSet(objects::RTD_0_IC3_PLOC_HEATSPREADER, MAX31865::MAX31865_SET_ID), + max31865PlocMissionboardSet(objects::RTD_1_IC4_PLOC_MISSIONBOARD, MAX31865::MAX31865_SET_ID) { ObjectManager::instance()->insert(objects::RTD_1_IC4_PLOC_MISSIONBOARD, this); ObjectManager::instance()->insert(objects::RTD_2_IC5_4K_CAMERA, this); ObjectManager::instance()->insert(objects::RTD_3_IC6_DAC_HEATSPREADER, this); @@ -37,6 +38,8 @@ ReturnValue_t TemperatureSensorsDummy::initialize() { } } + max31865PlocHeatspreaderSet.temperatureCelcius = 20.0; + max31865PlocMissionboardSet.temperatureCelcius = 20.0; return returnvalue::OK; } @@ -48,18 +51,18 @@ void TemperatureSensorsDummy::performControlOperation() { iteration++; value = sin(iteration / 80. * M_PI) * 10; - ReturnValue_t result = max31865Set.read(); + ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { sif::warning << "Failed to read temperature from MAX31865 dataset" << std::endl; } - max31865Set.rtdValue = value - 5; - max31865Set.temperatureCelcius = value; + max31865PlocHeatspreaderSet.rtdValue = value - 5; + max31865PlocHeatspreaderSet.temperatureCelcius = value; if ((iteration % 100) < 20) { - max31865Set.setValidity(false, true); + max31865PlocHeatspreaderSet.setValidity(false, true); } else { - max31865Set.setValidity(true, true); + max31865PlocHeatspreaderSet.setValidity(true, true); } - max31865Set.commit(); + max31865PlocHeatspreaderSet.commit(); } ReturnValue_t TemperatureSensorsDummy::initializeLocalDataPool( @@ -78,11 +81,12 @@ ReturnValue_t TemperatureSensorsDummy::initializeLocalDataPool( LocalPoolDataSetBase* TemperatureSensorsDummy::getDataSetHandle(sid_t sid) { sif::debug << "getHandle" << std::endl; - switch (sid.ownerSetId) { - case MAX31865::MAX31865_SET_ID: - return &max31865Set; - default: - return nullptr; + if (sid.objectId == objects::RTD_0_IC3_PLOC_HEATSPREADER) { + return &max31865PlocHeatspreaderSet; + } else if (sid.objectId == objects::RTD_1_IC4_PLOC_MISSIONBOARD) { + return &max31865PlocMissionboardSet; + } else { + return nullptr; } } diff --git a/dummies/TemperatureSensorsDummy.h b/dummies/TemperatureSensorsDummy.h index e41a9af0..0fcdfadb 100644 --- a/dummies/TemperatureSensorsDummy.h +++ b/dummies/TemperatureSensorsDummy.h @@ -23,7 +23,8 @@ class TemperatureSensorsDummy : public ExtendedControllerBase { private: int iteration = 0; float value = 0; - MAX31865::Max31865Set max31865Set; + MAX31865::Max31865Set max31865PlocHeatspreaderSet; + MAX31865::Max31865Set max31865PlocMissionboardSet; void noise(); }; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 45f26f8b..3e228ad5 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -102,6 +102,8 @@ void ThermalController::performControlOperation() { copyDevices(); deviceTemperatures.commit(); } + + // TODO: Heater control } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 5071d811..d401c5b5 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,6 +8,12 @@ #include #include +struct TempLimits { + TempLimits(float lowerLimit, float upperLimit) : lowerLimit(lowerLimit), upperLimit(upperLimit) {} + float lowerLimit; + float upperLimit; +}; + class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; @@ -75,6 +81,8 @@ class ThermalController : public ExtendedControllerBase { SUS::SusDataset susSet10; SUS::SusDataset susSet11; + TempLimits eBandLimits = TempLimits(10.0, 20.0); + // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 9f800bec..0c16d3ea 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -102,12 +102,13 @@ class SensorTemperatures : public StaticLocalDataSet 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_dro = lp_var_t(sid.objectId, PoolIds::SENSOR_DRO, 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); + // 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 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_tx_modul = lp_var_t(sid.objectId, PoolIds::SENSOR_TX_MODUL, this); - lp_var_t sensor_mpa = lp_var_t(sid.objectId, PoolIds::SENSOR_MPA, this); lp_var_t sensor_acu = lp_var_t(sid.objectId, PoolIds::SENSOR_ACU, this); lp_var_t sensor_plpcdu_heatspreader = lp_var_t(sid.objectId, PoolIds::SENSOR_PLPCDU_HEATSPREADER, this); diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 17bdf640..61a44de6 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -322,7 +322,7 @@ HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers swi } ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, ReturnValue_t onOff) { - return sendSwitchCommand(heater, onOff); + return sendSwitchCommand(heater, onOff); } bool HeaterHandler::allSwitchesOff() { diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index dce6454a..271e1bd1 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -40,7 +40,8 @@ class HeaterHandler : public ExecutableObjectIF, public PowerSwitchIF, public SystemObject, public HasActionsIF { - friend class ThermalController; + friend class ThermalController; + public: static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; @@ -60,7 +61,7 @@ class HeaterHandler : public ExecutableObjectIF, virtual ~HeaterHandler(); -protected: + protected: ReturnValue_t switchHeater(heater::Switchers heater, ReturnValue_t onOff); ReturnValue_t performOperation(uint8_t operationCode = 0) override; From d980c0404c8d4c7558365fd3b2c7a72817060bd9 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 23 Nov 2022 19:38:30 +0100 Subject: [PATCH 03/59] thermalcontroller constructor added --- mission/controller/ThermalController.cpp | 3 ++- mission/controller/ThermalController.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 3e228ad5..10a14b15 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -14,8 +14,9 @@ #include #include -ThermalController::ThermalController(object_id_t objectId) +ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), + heater(heater), sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index d401c5b5..03024542 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -18,7 +18,7 @@ class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; - ThermalController(object_id_t objectId); + ThermalController(object_id_t objectId, HeaterHandler& heater); ReturnValue_t initialize() override; From f35ed8101a9c4f6e80c82d2ca91819f4dce445c2 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 23 Nov 2022 19:45:37 +0100 Subject: [PATCH 04/59] renamed heater_7_s_band --- common/config/devices/heaterSwitcherList.h | 2 +- mission/controller/ThermalController.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/config/devices/heaterSwitcherList.h b/common/config/devices/heaterSwitcherList.h index 68034117..8f91385d 100644 --- a/common/config/devices/heaterSwitcherList.h +++ b/common/config/devices/heaterSwitcherList.h @@ -12,7 +12,7 @@ enum Switchers : uint8_t { HEATER_4_CAMERA, HEATER_5_STR, HEATER_6_DRO, - HEATER_7_HPA, + HEATER_7_S_BAND, NUMBER_OF_SWITCHES }; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 03024542..d69bc4cc 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -12,6 +12,8 @@ struct TempLimits { TempLimits(float lowerLimit, float upperLimit) : lowerLimit(lowerLimit), upperLimit(upperLimit) {} float lowerLimit; float upperLimit; + //TODO define limits + }; class ThermalController : public ExtendedControllerBase { From 92b732a189a344fdff408df1145d99fc41fb8d34 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 24 Nov 2022 11:35:05 +0100 Subject: [PATCH 05/59] existing TempLimits defined --- mission/controller/ThermalController.h | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index d69bc4cc..9ab14d87 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -9,9 +9,11 @@ #include struct TempLimits { - TempLimits(float lowerLimit, float upperLimit) : lowerLimit(lowerLimit), upperLimit(upperLimit) {} - float lowerLimit; - float upperLimit; + TempLimits(float opLowerLimit, float opUpperLimit, float nopLowerLimit, float nsopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), nopLowerLimit(nopLowerLimit), nopUpperLimit(nopUpperLimit) {} + float opLowerLimit; + float opUpperLimit; + float nopLowerLimit; + float nopUpperLimit; //TODO define limits }; @@ -83,7 +85,24 @@ class ThermalController : public ExtendedControllerBase { SUS::SusDataset susSet10; SUS::SusDataset susSet11; - TempLimits eBandLimits = TempLimits(10.0, 20.0); + //TempLimits + //TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + //TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + TempLimits cameraLimits = TempLimits(-30.0, 65.0, -40.0, 85.0); + TempLimits dacHeatspreaderLimits = TempLimits(-40.0, 118.0, -65.0, 150.0); + TempLimits strLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + TempLimits rw1Limits = TempLimits(-40.0, 85.0, -40.0, 85.0); + //TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + TempLimits scexLimits = TempLimits(-40.0, 85.0, -60.0, 150.0); + //TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0); + //TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + //TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + //TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + TempLimits acuLimits = TempLimits(-35.0, 85.0, -55.0, 150.0); //TODO nopLimits + TempLimits plpcduHeatspreaderLimits = TempLimits(-40.0, 85.0, -65.0, 125.0); //TODO check + TempLimits tcsBoardLimits = TempLimits(-40.0, 85.0, -60.0, 130.0); + TempLimits magnettorquerLimits = TempLimits(-40.0, 70.0, -30.0, 80.0); //TODO nopLimits + // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); From b52bade1502f86617f9bbfe432bc857d9568e6d9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Nov 2022 14:50:28 +0100 Subject: [PATCH 06/59] bump submodules --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index c5f91926..160ff799 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c5f91926c95a8db0c7921176aa3f62cc2bebef47 +Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca diff --git a/tmtc b/tmtc index d5813e1a..292bafa0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d5813e1a422beae7d0cb092a885e0956e9f1ddc1 +Subproject commit 292bafa0918d386e7f64bf9ed0e114a887420899 From 17a336ba0ab5a7fe4489ac05e08f699d8123e28b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Nov 2022 15:51:24 +0100 Subject: [PATCH 07/59] change ctor order --- mission/controller/ThermalController.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 9ab14d87..541737ba 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,8 +8,14 @@ #include #include +/** + * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit + * is exceeded. + * OP Limit: Soft limit. Device should be switched off or TCS controller should take action if the limit + * is exceeded to avoid reaching NOP limit + */ struct TempLimits { - TempLimits(float opLowerLimit, float opUpperLimit, float nopLowerLimit, float nsopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), nopLowerLimit(nopLowerLimit), nopUpperLimit(nopUpperLimit) {} + TempLimits(float nopLowerLimit, float opLowerLimit, float opUpperLimit, float nopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), nopLowerLimit(nopLowerLimit), nopUpperLimit(nopUpperLimit) {} float opLowerLimit; float opUpperLimit; float nopLowerLimit; @@ -88,20 +94,20 @@ class ThermalController : public ExtendedControllerBase { //TempLimits //TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); //TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits cameraLimits = TempLimits(-30.0, 65.0, -40.0, 85.0); - TempLimits dacHeatspreaderLimits = TempLimits(-40.0, 118.0, -65.0, 150.0); - TempLimits strLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits rw1Limits = TempLimits(-40.0, 85.0, -40.0, 85.0); + TempLimits cameraLimits = TempLimits(-40.0, -30.0, 65.0, 85.0); + TempLimits dacHeatspreaderLimits = TempLimits(-65.0, -40.0, 118.0, 150.0); + TempLimits strLimits = TempLimits(-30.0, -20.0, 70.0, 80.0); + TempLimits rw1Limits = TempLimits(-40.0, -40.0, 85.0, 85.0); //TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits scexLimits = TempLimits(-40.0, 85.0, -60.0, 150.0); + TempLimits scexLimits = TempLimits(-60.0, -40.0, 85.0, 150.0); //TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0); //TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); //TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); //TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits acuLimits = TempLimits(-35.0, 85.0, -55.0, 150.0); //TODO nopLimits - TempLimits plpcduHeatspreaderLimits = TempLimits(-40.0, 85.0, -65.0, 125.0); //TODO check - TempLimits tcsBoardLimits = TempLimits(-40.0, 85.0, -60.0, 130.0); - TempLimits magnettorquerLimits = TempLimits(-40.0, 70.0, -30.0, 80.0); //TODO nopLimits + TempLimits acuLimits = TempLimits(-55.0, -35.0, 85.0, 150.0); //TODO nopLimits + TempLimits plpcduHeatspreaderLimits = TempLimits(-65.0, -40.0, 85.0, 125.0); //TODO check + TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 85.0, 130.0); + TempLimits magnettorquerLimits = TempLimits(-40.0, -30.0, 70.0, 80.0); //TODO nopLimits // Initial delay to make sure all pool variables have been initialized their owners From f932c4c2c5880f5f64e1b63b765f62bbfe31b00c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Nov 2022 16:40:59 +0100 Subject: [PATCH 08/59] we need a dummy heater handler --- bsp_hosted/ObjectFactory.cpp | 2 +- .../fsfwconfig/objects/systemObjectList.h | 3 +- dummies/CMakeLists.txt | 2 +- dummies/TemperatureSensorInserter.cpp | 37 ++++++ dummies/TemperatureSensorInserter.h | 22 ++++ dummies/TemperatureSensorsDummy.cpp | 106 ------------------ dummies/TemperatureSensorsDummy.h | 30 ----- dummies/helpers.cpp | 5 +- mission/controller/ThermalController.cpp | 2 +- mission/controller/ThermalController.h | 40 ++++--- unittest/controller/testThermalController.cpp | 6 +- 11 files changed, 94 insertions(+), 161 deletions(-) create mode 100644 dummies/TemperatureSensorInserter.cpp create mode 100644 dummies/TemperatureSensorInserter.h delete mode 100644 dummies/TemperatureSensorsDummy.cpp delete mode 100644 dummies/TemperatureSensorsDummy.h diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 6db37e93..07e3163b 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -45,8 +45,8 @@ #include #include #include -#include +#include "../dummies/TemperatureSensorInserter.h" #include "dummies/helpers.h" #include "mission/utility/GlobalConfigHandler.h" diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index 703cd8b8..a1f9c20b 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -24,7 +24,8 @@ enum sourceObjects : uint32_t { /* 0x49 ('I') for Communication Interfaces **/ ARDUINO_COM_IF = 0x49000001, - DUMMY_COM_IF = 0x49000002 + DUMMY_COM_IF = 0x49000002, + THERMAL_TEMP_INSERTER = 0x49000003, }; } diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 677120fb..4f486f8a 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -1,6 +1,6 @@ target_sources( ${LIB_DUMMIES} - PUBLIC TemperatureSensorsDummy.cpp + PUBLIC TemperatureSensorInserter.cpp SusDummy.cpp BpxDummy.cpp ComIFDummy.cpp diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp new file mode 100644 index 00000000..ed71968c --- /dev/null +++ b/dummies/TemperatureSensorInserter.cpp @@ -0,0 +1,37 @@ +#include "TemperatureSensorInserter.h" + +#include + +#include +#include + +TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId) + : SystemObject(objects::THERMAL_CONTROLLER), + max31865PlocHeatspreaderSet(objects::RTD_0_IC3_PLOC_HEATSPREADER, MAX31865::MAX31865_SET_ID), + max31865PlocMissionboardSet(objects::RTD_1_IC4_PLOC_MISSIONBOARD, MAX31865::MAX31865_SET_ID) { +} + +ReturnValue_t TemperatureSensorInserter::initialize() { + max31865PlocHeatspreaderSet.temperatureCelcius = 20.0; + max31865PlocMissionboardSet.temperatureCelcius = 20.0; + return returnvalue::OK; +} + +ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { + iteration++; + value = sin(iteration / 80. * M_PI) * 10; + + ReturnValue_t result = max31865PlocHeatspreaderSet.read(); + if (result != returnvalue::OK) { + sif::warning << "Failed to read temperature from MAX31865 dataset" << std::endl; + } + max31865PlocHeatspreaderSet.rtdValue = value - 5; + max31865PlocHeatspreaderSet.temperatureCelcius = value; + if ((iteration % 100) < 20) { + max31865PlocHeatspreaderSet.setValidity(false, true); + } else { + max31865PlocHeatspreaderSet.setValidity(true, true); + } + max31865PlocHeatspreaderSet.commit(); + return returnvalue::OK; +} diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h new file mode 100644 index 00000000..84b1bcdb --- /dev/null +++ b/dummies/TemperatureSensorInserter.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { + public: + TemperatureSensorInserter(object_id_t objectId); + + ReturnValue_t initialize() override; + + protected: + ReturnValue_t performOperation(uint8_t opCode) override; + + private: + int iteration = 0; + float value = 0; + MAX31865::Max31865Set max31865PlocHeatspreaderSet; + MAX31865::Max31865Set max31865PlocMissionboardSet; + + void noise(); +}; diff --git a/dummies/TemperatureSensorsDummy.cpp b/dummies/TemperatureSensorsDummy.cpp deleted file mode 100644 index 3f6a4d83..00000000 --- a/dummies/TemperatureSensorsDummy.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "TemperatureSensorsDummy.h" - -#include - -#include -#include - -TemperatureSensorsDummy::TemperatureSensorsDummy() - : ExtendedControllerBase(objects::RTD_0_IC3_PLOC_HEATSPREADER), - max31865PlocHeatspreaderSet(objects::RTD_0_IC3_PLOC_HEATSPREADER, MAX31865::MAX31865_SET_ID), - max31865PlocMissionboardSet(objects::RTD_1_IC4_PLOC_MISSIONBOARD, MAX31865::MAX31865_SET_ID) { - ObjectManager::instance()->insert(objects::RTD_1_IC4_PLOC_MISSIONBOARD, this); - ObjectManager::instance()->insert(objects::RTD_2_IC5_4K_CAMERA, this); - ObjectManager::instance()->insert(objects::RTD_3_IC6_DAC_HEATSPREADER, this); - ObjectManager::instance()->insert(objects::RTD_4_IC7_STARTRACKER, this); - ObjectManager::instance()->insert(objects::RTD_5_IC8_RW1_MX_MY, this); - ObjectManager::instance()->insert(objects::RTD_6_IC9_DRO, this); - ObjectManager::instance()->insert(objects::RTD_7_IC10_SCEX, this); - ObjectManager::instance()->insert(objects::RTD_8_IC11_X8, this); - ObjectManager::instance()->insert(objects::RTD_9_IC12_HPA, this); - ObjectManager::instance()->insert(objects::RTD_10_IC13_PL_TX, this); - ObjectManager::instance()->insert(objects::RTD_11_IC14_MPA, this); - ObjectManager::instance()->insert(objects::RTD_12_IC15_ACU, this); - ObjectManager::instance()->insert(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, this); - ObjectManager::instance()->insert(objects::RTD_14_IC17_TCS_BOARD, this); - ObjectManager::instance()->insert(objects::RTD_15_IC18_IMTQ, this); - ObjectManager::instance()->insert(objects::TMP1075_HANDLER_TCS_0, this); - ObjectManager::instance()->insert(objects::TMP1075_HANDLER_TCS_1, this); - - ObjectManager::instance()->insert(objects::TMP1075_HANDLER_PLPCDU_0, this); - ObjectManager::instance()->insert(objects::TMP1075_HANDLER_PLPCDU_1, this); - ObjectManager::instance()->insert(objects::TMP1075_HANDLER_IF_BOARD, this); -} - -ReturnValue_t TemperatureSensorsDummy::initialize() { - static bool done = false; - if (not done) { - done = true; - ReturnValue_t result = ExtendedControllerBase::initialize(); - if (result != returnvalue::OK) { - return result; - } - } - - max31865PlocHeatspreaderSet.temperatureCelcius = 20.0; - max31865PlocMissionboardSet.temperatureCelcius = 20.0; - return returnvalue::OK; -} - -ReturnValue_t TemperatureSensorsDummy::handleCommandMessage(CommandMessage* message) { - return returnvalue::FAILED; -} - -void TemperatureSensorsDummy::performControlOperation() { - iteration++; - value = sin(iteration / 80. * M_PI) * 10; - - ReturnValue_t result = max31865PlocHeatspreaderSet.read(); - if (result != returnvalue::OK) { - sif::warning << "Failed to read temperature from MAX31865 dataset" << std::endl; - } - max31865PlocHeatspreaderSet.rtdValue = value - 5; - max31865PlocHeatspreaderSet.temperatureCelcius = value; - if ((iteration % 100) < 20) { - max31865PlocHeatspreaderSet.setValidity(false, true); - } else { - max31865PlocHeatspreaderSet.setValidity(true, true); - } - max31865PlocHeatspreaderSet.commit(); -} - -ReturnValue_t TemperatureSensorsDummy::initializeLocalDataPool( - localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(static_cast(MAX31865::PoolIds::RTD_VALUE), - new PoolEntry({0})); - localDataPoolMap.emplace(static_cast(MAX31865::PoolIds::TEMPERATURE_C), - new PoolEntry({0})); - localDataPoolMap.emplace(static_cast(MAX31865::PoolIds::LAST_FAULT_BYTE), - new PoolEntry({0})); - localDataPoolMap.emplace(static_cast(MAX31865::PoolIds::FAULT_BYTE), - new PoolEntry({0})); - - return returnvalue::OK; -} - -LocalPoolDataSetBase* TemperatureSensorsDummy::getDataSetHandle(sid_t sid) { - sif::debug << "getHandle" << std::endl; - if (sid.objectId == objects::RTD_0_IC3_PLOC_HEATSPREADER) { - return &max31865PlocHeatspreaderSet; - } else if (sid.objectId == objects::RTD_1_IC4_PLOC_MISSIONBOARD) { - return &max31865PlocMissionboardSet; - } else { - return nullptr; - } -} - -ReturnValue_t TemperatureSensorsDummy::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t* msToReachTheMode) { - if (submode != SUBMODE_NONE) { - return INVALID_SUBMODE; - } - if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) { - return INVALID_MODE; - } - return returnvalue::OK; -} diff --git a/dummies/TemperatureSensorsDummy.h b/dummies/TemperatureSensorsDummy.h deleted file mode 100644 index 0fcdfadb..00000000 --- a/dummies/TemperatureSensorsDummy.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include - -class TemperatureSensorsDummy : public ExtendedControllerBase { - public: - TemperatureSensorsDummy(); - - ReturnValue_t initialize() override; - - protected: - virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; - virtual void performControlOperation() override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - - // Mode abstract functions - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t* msToReachTheMode) override; - - private: - int iteration = 0; - float value = 0; - MAX31865::Max31865Set max31865PlocHeatspreaderSet; - MAX31865::Max31865Set max31865PlocMissionboardSet; - - void noise(); -}; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index c489d3a0..9d449699 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -18,9 +18,10 @@ #include #include #include -#include #include +#include "TemperatureSensorInserter.h" + using namespace dummy; void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { @@ -66,7 +67,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { - new TemperatureSensorsDummy(); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); } new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 10a14b15..2026e851 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -16,7 +16,7 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) : ExtendedControllerBase(objectId), - heater(heater), + heaterHandler(heater), sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 541737ba..44e2fb1a 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,20 +8,25 @@ #include #include +#include "../devices/HeaterHandler.h" + /** * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit * is exceeded. - * OP Limit: Soft limit. Device should be switched off or TCS controller should take action if the limit - * is exceeded to avoid reaching NOP limit + * OP Limit: Soft limit. Device should be switched off or TCS controller should take action if the + * limit is exceeded to avoid reaching NOP limit */ struct TempLimits { - TempLimits(float nopLowerLimit, float opLowerLimit, float opUpperLimit, float nopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), nopLowerLimit(nopLowerLimit), nopUpperLimit(nopUpperLimit) {} + TempLimits(float nopLowerLimit, float opLowerLimit, float opUpperLimit, float nopUpperLimit) + : opLowerLimit(opLowerLimit), + opUpperLimit(opUpperLimit), + nopLowerLimit(nopLowerLimit), + nopUpperLimit(nopUpperLimit) {} float opLowerLimit; float opUpperLimit; float nopLowerLimit; float nopUpperLimit; - //TODO define limits - + // TODO define limits }; class ThermalController : public ExtendedControllerBase { @@ -50,6 +55,8 @@ class ThermalController : public ExtendedControllerBase { InternalState internalState = InternalState::STARTUP; + HeaterHandler& heaterHandler; + thermalControllerDefinitions::SensorTemperatures sensorTemperatures; thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; @@ -91,24 +98,23 @@ class ThermalController : public ExtendedControllerBase { SUS::SusDataset susSet10; SUS::SusDataset susSet11; - //TempLimits - //TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - //TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits + // TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); TempLimits cameraLimits = TempLimits(-40.0, -30.0, 65.0, 85.0); TempLimits dacHeatspreaderLimits = TempLimits(-65.0, -40.0, 118.0, 150.0); TempLimits strLimits = TempLimits(-30.0, -20.0, 70.0, 80.0); TempLimits rw1Limits = TempLimits(-40.0, -40.0, 85.0, 85.0); - //TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); TempLimits scexLimits = TempLimits(-60.0, -40.0, 85.0, 150.0); - //TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0); - //TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - //TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - //TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits acuLimits = TempLimits(-55.0, -35.0, 85.0, 150.0); //TODO nopLimits - TempLimits plpcduHeatspreaderLimits = TempLimits(-65.0, -40.0, 85.0, 125.0); //TODO check + // TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + // TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); + TempLimits acuLimits = TempLimits(-55.0, -35.0, 85.0, 150.0); // TODO nopLimits + TempLimits plpcduHeatspreaderLimits = TempLimits(-65.0, -40.0, 85.0, 125.0); // TODO check TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 85.0, 130.0); - TempLimits magnettorquerLimits = TempLimits(-40.0, -30.0, 70.0, 80.0); //TODO nopLimits - + TempLimits magnettorquerLimits = TempLimits(-40.0, -30.0, 70.0, 80.0); // TODO nopLimits // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 3fac0f4e..976f3c4b 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,12 +6,15 @@ #include +#include "../../dummies/TemperatureSensorInserter.h" #include "../testEnvironment.h" TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; - new TemperatureSensorsDummy(); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); + // TODO: Create dummy heater handler + // new HeaterHandler() new SusDummy(); // testEnvironment::initialize(); From ad168f18b3d88d5cfa59c123e507e850921d1f10 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 24 Nov 2022 19:41:57 +0100 Subject: [PATCH 09/59] bugfixes --- bsp_hosted/ObjectFactory.cpp | 14 ++++++++++---- dummies/CMakeLists.txt | 3 ++- dummies/DummyHeaterHandler.cpp | 6 ++++++ dummies/DummyHeaterHandler.h | 13 +++++++++++++ dummies/TemperatureSensorInserter.cpp | 2 +- fsfw | 2 +- linux/ObjectFactory.cpp | 13 ------------- linux/ObjectFactory.h | 3 ++- mission/core/GenericFactory.cpp | 24 ++++++++++++++++++++++++ mission/core/GenericFactory.h | 6 ++++++ mission/devices/HeaterHandler.h | 3 ++- tmtc | 2 +- 12 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 dummies/DummyHeaterHandler.cpp create mode 100644 dummies/DummyHeaterHandler.h diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 07e3163b..0c62efc2 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -10,10 +10,8 @@ #include "OBSWConfig.h" #include "devConf.h" -#include "eive/definitions.h" #include "fsfw/platform.h" #include "fsfw_tests/integration/task/TestTask.h" -#include "tmtc/pusIds.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTcPollingTask.h" @@ -79,7 +77,7 @@ void ObjectFactory::produce(void* args) { CfdpTmFunnel* cfdpFunnel; ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel); - DummyGpioIF* dummyGpioIF = new DummyGpioIF(); + auto* dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); static_cast(dummyGpioIF); #ifdef PLATFORM_UNIX @@ -109,6 +107,14 @@ void ObjectFactory::produce(void* args) { dummy::DummyCfg cfg; dummy::createDummies(cfg, *dummySwitcher); - new ThermalController(objects::THERMAL_CONTROLLER); + + HeaterHandler* heaterHandler = nullptr; + //new ThermalController(objects::THERMAL_CONTROLLER); + ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler); + if(heaterHandler == nullptr){ + sif::error << "HeaterHandler could not be created" << std::endl; + }else{ + ObjectFactory::createThermalController(*heaterHandler); + } new TestTask(objects::TEST_TASK); } diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 4f486f8a..6b499d7b 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -19,4 +19,5 @@ target_sources( PlPcduDummy.cpp CoreControllerDummy.cpp helpers.cpp - MgmRm3100Dummy.cpp) + MgmRm3100Dummy.cpp +DummyHeaterHandler.cpp) diff --git a/dummies/DummyHeaterHandler.cpp b/dummies/DummyHeaterHandler.cpp new file mode 100644 index 00000000..d006038e --- /dev/null +++ b/dummies/DummyHeaterHandler.cpp @@ -0,0 +1,6 @@ +// +// Created by irini on 24.11.22. +// +#include "DummyHeaterHandler.h" + + diff --git a/dummies/DummyHeaterHandler.h b/dummies/DummyHeaterHandler.h new file mode 100644 index 00000000..b0628c09 --- /dev/null +++ b/dummies/DummyHeaterHandler.h @@ -0,0 +1,13 @@ +// +// Created by irini on 24.11.22. +// + +#ifndef EIVE_OBSW_DUMMYHEATERHANDLER_H +#define EIVE_OBSW_DUMMYHEATERHANDLER_H + +#include "mission/devices/HeaterHandler.h" +class DummyHeaterHandler: public HeaterHandler{ + public: + //DummyHeaterHandler(); +}; +#endif // EIVE_OBSW_DUMMYHEATERHANDLER_H diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index ed71968c..314f7496 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -6,7 +6,7 @@ #include TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId) - : SystemObject(objects::THERMAL_CONTROLLER), + : SystemObject(objects::THERMAL_TEMP_INSERTER), max31865PlocHeatspreaderSet(objects::RTD_0_IC3_PLOC_HEATSPREADER, MAX31865::MAX31865_SET_ID), max31865PlocMissionboardSet(objects::RTD_1_IC4_PLOC_MISSIONBOARD, MAX31865::MAX31865_SET_ID) { } diff --git a/fsfw b/fsfw index 160ff799..c5f91926 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca +Subproject commit c5f91926c95a8db0c7921176aa3f62cc2bebef47 diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index e35d7e96..6ca221f1 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,23 +9,14 @@ #include #include #include -#include #include -#include -#include -#include #include -#include -#include -#include #include "OBSWConfig.h" #include "devConf.h" #include "devices/addresses.h" #include "devices/gpioIds.h" #include "eive/definitions.h" -#include "mission/system/objects/SusAssembly.h" -#include "mission/system/objects/TcsBoardAssembly.h" #include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/payloadModeTree.h" @@ -340,10 +331,6 @@ void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwr scexHandler->connectModeTreeParent(satsystem::pl::SUBSYSTEM); } -void ObjectFactory::createThermalController() { - new ThermalController(objects::THERMAL_CONTROLLER); -} - AcsController* ObjectFactory::createAcsController(bool connectSubsystem) { auto acsCtrl = new AcsController(objects::ACS_CONTROLLER); if (connectSubsystem) { diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 3704e9bd..10b70df0 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -11,6 +11,8 @@ #include #include +#include "mission/devices/HeaterHandler.h" + class GpioIF; class SpiComIF; class PowerSwitchIF; @@ -29,7 +31,6 @@ void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, void gpioChecker(ReturnValue_t result, std::string output); -void createThermalController(); AcsController* createAcsController(bool connectSubsystem); void addTmtcIpCoresToFunnels(CcsdsIpCoreHandler& ipCoreHandler, PusTmFunnel& pusFunnel, diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 114451b2..c881c3e1 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -36,8 +36,12 @@ #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TMTC_TCP_BRIDGE == 0 // UDP server includes +#include "devices/gpioIds.h" #include "fsfw/osal/common/UdpTcPollingTask.h" #include "fsfw/osal/common/UdpTmTcBridge.h" +#include "mission/controller/ThermalController.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #else // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" @@ -179,3 +183,23 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun ccsdsDistrib->registerApplication(info); #endif } + +void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler) { + HeaterHelper helper({{ + {new HealthDevice(objects::HEATER_0_PLOC_PROC_BRD, MessageQueueIF::NO_QUEUE), + gpioIds::HEATER_0}, + {new HealthDevice(objects::HEATER_1_PCDU_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_1}, + {new HealthDevice(objects::HEATER_2_ACS_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_2}, + {new HealthDevice(objects::HEATER_3_OBC_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_3}, + {new HealthDevice(objects::HEATER_4_CAMERA, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_4}, + {new HealthDevice(objects::HEATER_5_STR, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_5}, + {new HealthDevice(objects::HEATER_6_DRO, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_6}, + {new HealthDevice(objects::HEATER_7_HPA, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_7}, + }}); + heaterHandler = new HeaterHandler(objects::HEATER_HANDLER, &gpioIF, helper, &pwrSwitcher, + pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); +} + +void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { + new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler); +} \ No newline at end of file diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 2e2b0748..1704ef11 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,6 +1,10 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw/power/PowerSwitchIF.h" + +class HeaterHandler; class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; @@ -9,7 +13,9 @@ namespace ObjectFactory { void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, CfdpTmFunnel** cfdpFunnel); +void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler); +void createThermalController(HeaterHandler& heaterHandler); } #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index 271e1bd1..caa90bc4 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -15,6 +15,7 @@ #include #include +#include #include #include "devices/heaterSwitcherList.h" @@ -28,7 +29,7 @@ using HeaterPair = std::pair; struct HeaterHelper { public: - HeaterHelper(std::array heaters) : heaters(heaters) {} + HeaterHelper(std::array heaters) : heaters(std::move(heaters)) {} std::array heaters = {}; }; /** diff --git a/tmtc b/tmtc index 292bafa0..d5813e1a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 292bafa0918d386e7f64bf9ed0e114a887420899 +Subproject commit d5813e1a422beae7d0cb092a885e0956e9f1ddc1 From 1f687ffc38d888dbf72b10cfdc35714d1bb76051 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 09:53:18 +0100 Subject: [PATCH 10/59] bump submodules --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index c5f91926..160ff799 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c5f91926c95a8db0c7921176aa3f62cc2bebef47 +Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca diff --git a/tmtc b/tmtc index d5813e1a..a54ae782 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d5813e1a422beae7d0cb092a885e0956e9f1ddc1 +Subproject commit a54ae782d46f6f405df8e62ab80b556f971df369 From 43ed7d4bc5aae164c4f007f2d4790d4b307c4733 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:13:24 +0100 Subject: [PATCH 11/59] create temp sensor dummies --- bsp_hosted/ObjectFactory.cpp | 6 ++-- dummies/CMakeLists.txt | 4 ++- dummies/DummyHeaterHandler.cpp | 2 -- dummies/DummyHeaterHandler.h | 4 +-- dummies/ImtqDummy.cpp | 2 +- dummies/ImtqDummy.h | 2 +- dummies/Max31865Dummy.cpp | 30 +++++++++++++++++ dummies/Max31865Dummy.h | 29 +++++++++++++++++ dummies/TemperatureSensorInserter.h | 4 +-- dummies/Tmp1075Dummy.cpp | 30 +++++++++++++++++ dummies/Tmp1075Dummy.h | 26 +++++++++++++++ mission/controller/ThermalController.h | 32 +++++++++---------- mission/core/GenericFactory.cpp | 5 +-- mission/core/GenericFactory.h | 7 ++-- mission/devices/HeaterHandler.h | 3 +- mission/devices/Max31865EiveHandler.h | 2 +- mission/devices/Max31865PT1000Handler.h | 2 +- .../devicedefinitions/Max31865Definitions.h | 6 ++-- 18 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 dummies/Max31865Dummy.cpp create mode 100644 dummies/Max31865Dummy.h create mode 100644 dummies/Tmp1075Dummy.cpp create mode 100644 dummies/Tmp1075Dummy.h diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 0c62efc2..ce281b09 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -109,11 +109,11 @@ void ObjectFactory::produce(void* args) { dummy::createDummies(cfg, *dummySwitcher); HeaterHandler* heaterHandler = nullptr; - //new ThermalController(objects::THERMAL_CONTROLLER); + // new ThermalController(objects::THERMAL_CONTROLLER); ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler); - if(heaterHandler == nullptr){ + if (heaterHandler == nullptr) { sif::error << "HeaterHandler could not be created" << std::endl; - }else{ + } else { ObjectFactory::createThermalController(*heaterHandler); } new TestTask(objects::TEST_TASK); diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 6b499d7b..f2aa3e7a 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -6,6 +6,7 @@ target_sources( ComIFDummy.cpp ComCookieDummy.cpp RwDummy.cpp + Max31865Dummy.cpp StarTrackerDummy.cpp SyrlinksDummy.cpp ImtqDummy.cpp @@ -20,4 +21,5 @@ target_sources( CoreControllerDummy.cpp helpers.cpp MgmRm3100Dummy.cpp -DummyHeaterHandler.cpp) + Tmp1075Dummy.cpp + DummyHeaterHandler.cpp) diff --git a/dummies/DummyHeaterHandler.cpp b/dummies/DummyHeaterHandler.cpp index d006038e..59c49bde 100644 --- a/dummies/DummyHeaterHandler.cpp +++ b/dummies/DummyHeaterHandler.cpp @@ -2,5 +2,3 @@ // Created by irini on 24.11.22. // #include "DummyHeaterHandler.h" - - diff --git a/dummies/DummyHeaterHandler.h b/dummies/DummyHeaterHandler.h index b0628c09..8fb1e80b 100644 --- a/dummies/DummyHeaterHandler.h +++ b/dummies/DummyHeaterHandler.h @@ -6,8 +6,8 @@ #define EIVE_OBSW_DUMMYHEATERHANDLER_H #include "mission/devices/HeaterHandler.h" -class DummyHeaterHandler: public HeaterHandler{ +class DummyHeaterHandler : public HeaterHandler { public: - //DummyHeaterHandler(); + // DummyHeaterHandler(); }; #endif // EIVE_OBSW_DUMMYHEATERHANDLER_H diff --git a/dummies/ImtqDummy.cpp b/dummies/ImtqDummy.cpp index aad1478b..1159290b 100644 --- a/dummies/ImtqDummy.cpp +++ b/dummies/ImtqDummy.cpp @@ -5,7 +5,7 @@ ImtqDummy::ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie) {} -ImtqDummy::~ImtqDummy() {} +ImtqDummy::~ImtqDummy() = default; void ImtqDummy::doStartUp() {} diff --git a/dummies/ImtqDummy.h b/dummies/ImtqDummy.h index 4b5557ef..0cfdf518 100644 --- a/dummies/ImtqDummy.h +++ b/dummies/ImtqDummy.h @@ -12,7 +12,7 @@ class ImtqDummy : public DeviceHandlerBase { static const uint8_t PERIODIC_REPLY_DATA = 2; ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); - virtual ~ImtqDummy(); + ~ImtqDummy() override; protected: void doStartUp() override; diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp new file mode 100644 index 00000000..7b5f19c3 --- /dev/null +++ b/dummies/Max31865Dummy.cpp @@ -0,0 +1,30 @@ +#include "Max31865Dummy.h" + +using namespace returnvalue; + +Max31865Dummy::Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie), set(this, EiveMax31855::EXCHANGE_SET_ID) {} +void Max31865Dummy::doStartUp() { setMode(MODE_ON); } +void Max31865Dummy::doShutDown() { setMode(_MODE_POWER_DOWN); } +ReturnValue_t Max31865Dummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} +ReturnValue_t Max31865Dummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return OK; } +ReturnValue_t Max31865Dummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return 0; +} +ReturnValue_t Max31865Dummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return 0; +} +ReturnValue_t Max31865Dummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return 0; +} +void Max31865Dummy::fillCommandAndReplyMap() {} +uint32_t Max31865Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } +ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); +} diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h new file mode 100644 index 00000000..b10d1667 --- /dev/null +++ b/dummies/Max31865Dummy.h @@ -0,0 +1,29 @@ +#ifndef EIVE_OBSW_MAX31865DUMMY_H +#define EIVE_OBSW_MAX31865DUMMY_H + +#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" + +class Max31865Dummy : public DeviceHandlerBase { + public: + Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + + private: + MAX31865::PrimarySet set; + + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; + +#endif // EIVE_OBSW_MAX31865DUMMY_H diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 84b1bcdb..74221458 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -15,8 +15,8 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject private: int iteration = 0; float value = 0; - MAX31865::Max31865Set max31865PlocHeatspreaderSet; - MAX31865::Max31865Set max31865PlocMissionboardSet; + MAX31865::PrimarySet max31865PlocHeatspreaderSet; + MAX31865::PrimarySet max31865PlocMissionboardSet; void noise(); }; diff --git a/dummies/Tmp1075Dummy.cpp b/dummies/Tmp1075Dummy.cpp new file mode 100644 index 00000000..8c7653b1 --- /dev/null +++ b/dummies/Tmp1075Dummy.cpp @@ -0,0 +1,30 @@ +#include "Tmp1075Dummy.h" + +using namespace returnvalue; + +Tmp1075Dummy::Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} +void Tmp1075Dummy::doStartUp() { setMode(MODE_ON); } +void Tmp1075Dummy::doShutDown() { setMode(_MODE_POWER_DOWN); } +ReturnValue_t Tmp1075Dummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} +ReturnValue_t Tmp1075Dummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return OK; } +ReturnValue_t Tmp1075Dummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return 0; +} +ReturnValue_t Tmp1075Dummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return 0; +} +ReturnValue_t Tmp1075Dummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return 0; +} +void Tmp1075Dummy::fillCommandAndReplyMap() {} +uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } +ReturnValue_t Tmp1075Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); +} diff --git a/dummies/Tmp1075Dummy.h b/dummies/Tmp1075Dummy.h new file mode 100644 index 00000000..ad229aff --- /dev/null +++ b/dummies/Tmp1075Dummy.h @@ -0,0 +1,26 @@ +#ifndef EIVE_OBSW_TMP1075DUMMY_H +#define EIVE_OBSW_TMP1075DUMMY_H + +#include "fsfw/devicehandlers/DeviceHandlerBase.h" + +class Tmp1075Dummy : public DeviceHandlerBase { + public: + Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + + private: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; + +#endif // EIVE_OBSW_TMP1075DUMMY_H diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 44e2fb1a..9cbddab1 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -62,22 +62,22 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; // Temperature Sensors - MAX31865::Max31865Set max31865Set0; - MAX31865::Max31865Set max31865Set1; - MAX31865::Max31865Set max31865Set2; - MAX31865::Max31865Set max31865Set3; - MAX31865::Max31865Set max31865Set4; - MAX31865::Max31865Set max31865Set5; - MAX31865::Max31865Set max31865Set6; - MAX31865::Max31865Set max31865Set7; - MAX31865::Max31865Set max31865Set8; - MAX31865::Max31865Set max31865Set9; - MAX31865::Max31865Set max31865Set10; - MAX31865::Max31865Set max31865Set11; - MAX31865::Max31865Set max31865Set12; - MAX31865::Max31865Set max31865Set13; - MAX31865::Max31865Set max31865Set14; - MAX31865::Max31865Set max31865Set15; + 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; TMP1075::Tmp1075Dataset tmp1075SetTcs0; TMP1075::Tmp1075Dataset tmp1075SetTcs1; TMP1075::Tmp1075Dataset tmp1075SetPlPcdu0; diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index c881c3e1..21274009 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -184,7 +184,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun #endif } -void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler) { +void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, + HeaterHandler*& heaterHandler) { HeaterHelper helper({{ {new HealthDevice(objects::HEATER_0_PLOC_PROC_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_0}, @@ -197,7 +198,7 @@ void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& {new HealthDevice(objects::HEATER_7_HPA, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_7}, }}); heaterHandler = new HeaterHandler(objects::HEATER_HANDLER, &gpioIF, helper, &pwrSwitcher, - pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); + pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); } void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 1704ef11..04802d51 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,8 +1,8 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ -#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw/power/PowerSwitchIF.h" +#include "fsfw_hal/common/gpio/GpioIF.h" class HeaterHandler; class HealthTableIF; @@ -13,9 +13,10 @@ namespace ObjectFactory { void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, CfdpTmFunnel** cfdpFunnel); -void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler); +void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, + HeaterHandler*& heaterHandler); void createThermalController(HeaterHandler& heaterHandler); -} +} // namespace ObjectFactory #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index caa90bc4..18bb7240 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -29,7 +29,8 @@ using HeaterPair = std::pair; struct HeaterHelper { public: - HeaterHelper(std::array heaters) : heaters(std::move(heaters)) {} + HeaterHelper(std::array heaters) + : heaters(std::move(heaters)) {} std::array heaters = {}; }; /** diff --git a/mission/devices/Max31865EiveHandler.h b/mission/devices/Max31865EiveHandler.h index 121929e7..6a030718 100644 --- a/mission/devices/Max31865EiveHandler.h +++ b/mission/devices/Max31865EiveHandler.h @@ -38,7 +38,7 @@ class Max31865EiveHandler : public DeviceHandlerBase { bool debugMode = false; size_t structLen = 0; bool instantNormal = false; - MAX31865::Max31865Set sensorDataset; + MAX31865::PrimarySet sensorDataset; PeriodicOperationDivider debugDivider; enum class InternalState { NONE, ON, ACTIVE, INACTIVE } state = InternalState::NONE; bool transitionOk = false; diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 6b136f13..5841c7b1 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -114,7 +114,7 @@ class Max31865PT1000Handler : public DeviceHandlerBase { uint8_t deviceIdx = 0; std::array commandBuffer{0}; - MAX31865::Max31865Set sensorDataset; + MAX31865::PrimarySet sensorDataset; sid_t sensorDatasetSid; #if OBSW_VERBOSE_LEVEL >= 1 diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index d7d6455d..057b2899 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -56,20 +56,20 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; -class Max31865Set : public StaticLocalDataSet<4> { +class PrimarySet : public StaticLocalDataSet<4> { public: /** * Constructor used by owner and data creators like device handlers. * @param owner * @param setId */ - Max31865Set(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {} + PrimarySet(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {} /** * Constructor used by data users like controllers. * @param sid */ - Max31865Set(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {} + PrimarySet(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {} lp_var_t rtdValue = lp_var_t(sid.objectId, static_cast(PoolIds::RTD_VALUE), this); From 4f25bdd121ee80e2c5e4c057899de24b143e8dd9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:19:45 +0100 Subject: [PATCH 12/59] map a few things --- dummies/Max31865Dummy.cpp | 7 +++++++ dummies/Max31865Dummy.h | 1 + dummies/Tmp1075Dummy.cpp | 10 +++++++--- dummies/Tmp1075Dummy.h | 6 ++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index 7b5f19c3..85120650 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -26,5 +26,12 @@ void Max31865Dummy::fillCommandAndReplyMap() {} uint32_t Max31865Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, 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::LAST_FAULT_BYTE), + new PoolEntry({0})); + localDataPoolMap.emplace(static_cast(PoolIds::FAULT_BYTE), new PoolEntry({0})); return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); } +LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index b10d1667..e8fce23b 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -24,6 +24,7 @@ class Max31865Dummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif // EIVE_OBSW_MAX31865DUMMY_H diff --git a/dummies/Tmp1075Dummy.cpp b/dummies/Tmp1075Dummy.cpp index 8c7653b1..9715a346 100644 --- a/dummies/Tmp1075Dummy.cpp +++ b/dummies/Tmp1075Dummy.cpp @@ -1,9 +1,11 @@ #include "Tmp1075Dummy.h" +#include "mission/devices/devicedefinitions/Tmp1075Definitions.h" + using namespace returnvalue; Tmp1075Dummy::Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) - : DeviceHandlerBase(objectId, comif, comCookie) {} + : DeviceHandlerBase(objectId, comif, comCookie), set(this) {} void Tmp1075Dummy::doStartUp() { setMode(MODE_ON); } void Tmp1075Dummy::doShutDown() { setMode(_MODE_POWER_DOWN); } ReturnValue_t Tmp1075Dummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { @@ -23,8 +25,10 @@ ReturnValue_t Tmp1075Dummy::interpretDeviceReply(DeviceCommandId_t id, const uin return 0; } void Tmp1075Dummy::fillCommandAndReplyMap() {} -uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } +uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } ReturnValue_t Tmp1075Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075, new PoolEntry({0.0})); + return OK; } +LocalPoolDataSetBase *Tmp1075Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/dummies/Tmp1075Dummy.h b/dummies/Tmp1075Dummy.h index ad229aff..e43ca8e2 100644 --- a/dummies/Tmp1075Dummy.h +++ b/dummies/Tmp1075Dummy.h @@ -2,12 +2,15 @@ #define EIVE_OBSW_TMP1075DUMMY_H #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "mission/devices/devicedefinitions/Tmp1075Definitions.h" class Tmp1075Dummy : public DeviceHandlerBase { public: Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); private: + TMP1075::Tmp1075Dataset set; + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; @@ -21,6 +24,9 @@ class Tmp1075Dummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + + protected: + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif // EIVE_OBSW_TMP1075DUMMY_H From 49524abeb74f49e2cc7916f55142f6429721e14d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:27:31 +0100 Subject: [PATCH 13/59] create temp sens dummies --- common/config/eive/objects.h | 1 - dummies/Max31865Dummy.cpp | 1 + dummies/Max31865Dummy.h | 1 + dummies/helpers.cpp | 25 ++++++++++++++++++++++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index a8911347..01aa1cf1 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -48,7 +48,6 @@ enum commonObjects : uint32_t { TMP1075_HANDLER_PLPCDU_0 = 0x44420006, TMP1075_HANDLER_PLPCDU_1 = 0x44420007, TMP1075_HANDLER_IF_BOARD = 0x44420008, - TMP1075_HANDLER_OBC_IF_BOARD = 0x44420009, PCDU_HANDLER = 0x442000A1, P60DOCK_HANDLER = 0x44250000, PDU1_HANDLER = 0x44250001, diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index 85120650..c86210e7 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -35,3 +35,4 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); } LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } +Max31865Dummy::Max31865Dummy(object_id_t objectId, CookieIF* cookie): DeviceHandlerBase(objectId, objects::DUMMY_COM_IF, cookie), set(this, EiveMax31855::EXCHANGE_SET_ID) {} diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index e8fce23b..70ba3c03 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -7,6 +7,7 @@ class Max31865Dummy : public DeviceHandlerBase { public: Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + Max31865Dummy(object_id_t objectId, CookieIF* comCookie); private: MAX31865::PrimarySet set; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 9d449699..50eacec5 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -18,6 +18,8 @@ #include #include #include +#include "dummies/Tmp1075Dummy.h" +#include "dummies/Max31865Dummy.h" #include #include "TemperatureSensorInserter.h" @@ -26,7 +28,7 @@ using namespace dummy; void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { new ComIFDummy(objects::DUMMY_COM_IF); - ComCookieDummy* comCookieDummy = new ComCookieDummy(); + auto* comCookieDummy = new ComCookieDummy(); new BpxDummy(objects::BPX_BATT_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); if (cfg.addCoreCtrlCfg) { new CoreControllerDummy(objects::CORE_CONTROLLER); @@ -67,6 +69,27 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { + new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_4_IC7_STARTRACKER, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_5_IC8_RW1_MX_MY, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_6_IC9_DRO, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_7_IC10_SCEX, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_8_IC11_X8, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_9_IC12_HPA, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy); + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy); + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy); + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy); + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy); + new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy); new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); } new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); From 5265575186971177216c976654a319d01860b410 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:27:47 +0100 Subject: [PATCH 14/59] afmt --- dummies/Max31865Dummy.cpp | 4 +++- dummies/Max31865Dummy.h | 2 +- dummies/helpers.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index c86210e7..e8343a4a 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -35,4 +35,6 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); } LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } -Max31865Dummy::Max31865Dummy(object_id_t objectId, CookieIF* cookie): DeviceHandlerBase(objectId, objects::DUMMY_COM_IF, cookie), set(this, EiveMax31855::EXCHANGE_SET_ID) {} +Max31865Dummy::Max31865Dummy(object_id_t objectId, CookieIF *cookie) + : DeviceHandlerBase(objectId, objects::DUMMY_COM_IF, cookie), + set(this, EiveMax31855::EXCHANGE_SET_ID) {} diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index 70ba3c03..011296d6 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -7,7 +7,7 @@ class Max31865Dummy : public DeviceHandlerBase { public: Max31865Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); - Max31865Dummy(object_id_t objectId, CookieIF* comCookie); + Max31865Dummy(object_id_t objectId, CookieIF *comCookie); private: MAX31865::PrimarySet set; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 50eacec5..1b7f705e 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -18,11 +18,11 @@ #include #include #include -#include "dummies/Tmp1075Dummy.h" -#include "dummies/Max31865Dummy.h" #include #include "TemperatureSensorInserter.h" +#include "dummies/Max31865Dummy.h" +#include "dummies/Tmp1075Dummy.h" using namespace dummy; @@ -82,7 +82,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy); new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy); new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); + new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, objects::DUMMY_COM_IF, + comCookieDummy); new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy); new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy); new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy); From 35cd18240c16c5979b6e61acea3db444c331720c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:37:10 +0100 Subject: [PATCH 15/59] generic scheduler function --- bsp_hosted/scheduling.cpp | 6 ++++++ bsp_q7s/core/InitMission.cpp | 28 ++-------------------------- dummies/Max31865Dummy.cpp | 2 +- mission/core/CMakeLists.txt | 2 +- mission/core/scheduling.cpp | 33 +++++++++++++++++++++++++++++++++ mission/core/scheduling.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 mission/core/scheduling.cpp create mode 100644 mission/core/scheduling.h diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 76a8f2e9..6525bde6 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -14,6 +14,7 @@ #include "OBSWConfig.h" #include "ObjectFactory.h" +#include "mission/core/scheduling.h" #include "scheduling.h" #ifdef LINUX @@ -183,6 +184,10 @@ void scheduling::initTasks() { } #endif /* OBSW_ADD_TEST_CODE == 1 */ + PeriodicTaskIF* tcsTask = factory->createPeriodicTask( + "TCS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); + scheduling::scheduleRtdSensors(tcsTask); + sif::info << "Starting tasks.." << std::endl; tmtcDistributor->startTask(); tmtcPollingTask->startTask(); @@ -195,6 +200,7 @@ void scheduling::initTasks() { pstTask->startTask(); thermalTask->startTask(); + tcsTask->startTask(); #if OBSW_ADD_PLOC_SUPERVISOR == 1 supvHelperTask->startTask(); #endif diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 3b1eb357..348f85f0 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -16,6 +16,7 @@ #include "fsfw/tasks/FixedTimeslotTaskIF.h" #include "fsfw/tasks/PeriodicTaskIF.h" #include "fsfw/tasks/TaskFactory.h" +#include "mission/core/scheduling.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/utility/InitMission.h" #include "pollingsequence/pollingSequenceFactory.h" @@ -202,32 +203,7 @@ void initmission::initTasks() { PeriodicTaskIF* tcsTask = factory->createPeriodicTask( "TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - std::array rtdIds = { - objects::RTD_0_IC3_PLOC_HEATSPREADER, - objects::RTD_1_IC4_PLOC_MISSIONBOARD, - objects::RTD_2_IC5_4K_CAMERA, - objects::RTD_3_IC6_DAC_HEATSPREADER, - objects::RTD_4_IC7_STARTRACKER, - objects::RTD_5_IC8_RW1_MX_MY, - objects::RTD_6_IC9_DRO, - objects::RTD_7_IC10_SCEX, - objects::RTD_8_IC11_X8, - objects::RTD_9_IC12_HPA, - objects::RTD_10_IC13_PL_TX, - objects::RTD_11_IC14_MPA, - objects::RTD_12_IC15_ACU, - objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - objects::RTD_14_IC17_TCS_BOARD, - objects::RTD_15_IC18_IMTQ, - }; - - for (const auto& rtd : rtdIds) { - tcsTask->addComponent(rtd, DeviceHandlerIF::PERFORM_OPERATION); - tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_WRITE); - tcsTask->addComponent(rtd, DeviceHandlerIF::GET_WRITE); - tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_READ); - tcsTask->addComponent(rtd, DeviceHandlerIF::GET_READ); - } + scheduling::scheduleTempSensors(tcsTask); #endif PeriodicTaskIF* tcsSystemTask = factory->createPeriodicTask( diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index e8343a4a..5cbd1dec 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -32,7 +32,7 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD localDataPoolMap.emplace(static_cast(PoolIds::LAST_FAULT_BYTE), new PoolEntry({0})); localDataPoolMap.emplace(static_cast(PoolIds::FAULT_BYTE), new PoolEntry({0})); - return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); + return OK; } LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } Max31865Dummy::Max31865Dummy(object_id_t objectId, CookieIF *cookie) diff --git a/mission/core/CMakeLists.txt b/mission/core/CMakeLists.txt index c7be4ac9..fc6e1cff 100644 --- a/mission/core/CMakeLists.txt +++ b/mission/core/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE GenericFactory.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE GenericFactory.cpp scheduling.cpp) diff --git a/mission/core/scheduling.cpp b/mission/core/scheduling.cpp new file mode 100644 index 00000000..fb119525 --- /dev/null +++ b/mission/core/scheduling.cpp @@ -0,0 +1,33 @@ +#include "scheduling.h" + +#include "fsfw/tasks/PeriodicTaskIF.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" + +void scheduling::scheduleRtdSensors(PeriodicTaskIF* tcsTask) { + std::array rtdIds = { + objects::RTD_0_IC3_PLOC_HEATSPREADER, + objects::RTD_1_IC4_PLOC_MISSIONBOARD, + objects::RTD_2_IC5_4K_CAMERA, + objects::RTD_3_IC6_DAC_HEATSPREADER, + objects::RTD_4_IC7_STARTRACKER, + objects::RTD_5_IC8_RW1_MX_MY, + objects::RTD_6_IC9_DRO, + objects::RTD_7_IC10_SCEX, + objects::RTD_8_IC11_X8, + objects::RTD_9_IC12_HPA, + objects::RTD_10_IC13_PL_TX, + objects::RTD_11_IC14_MPA, + objects::RTD_12_IC15_ACU, + objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + objects::RTD_14_IC17_TCS_BOARD, + objects::RTD_15_IC18_IMTQ, + }; + + for (const auto& rtd : rtdIds) { + tcsTask->addComponent(rtd, DeviceHandlerIF::PERFORM_OPERATION); + tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_WRITE); + tcsTask->addComponent(rtd, DeviceHandlerIF::GET_WRITE); + tcsTask->addComponent(rtd, DeviceHandlerIF::SEND_READ); + tcsTask->addComponent(rtd, DeviceHandlerIF::GET_READ); + } +} diff --git a/mission/core/scheduling.h b/mission/core/scheduling.h new file mode 100644 index 00000000..d6f68288 --- /dev/null +++ b/mission/core/scheduling.h @@ -0,0 +1,10 @@ +#ifndef EIVE_OBSW_SCHEDULING_H +#define EIVE_OBSW_SCHEDULING_H + +class PeriodicTaskIF; + +namespace scheduling { +void scheduleRtdSensors(PeriodicTaskIF* periodicTask); + +} +#endif // EIVE_OBSW_SCHEDULING_H From e223a6eac09c8a37820dd8b97f281042436e22ff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:47:23 +0100 Subject: [PATCH 16/59] some dumb warning remaining --- bsp_hosted/scheduling.cpp | 1 + dummies/TemperatureSensorInserter.h | 4 ++-- mission/core/scheduling.cpp | 16 +++++++++++++++- mission/core/scheduling.h | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 6525bde6..ef73cdaf 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -186,6 +186,7 @@ void scheduling::initTasks() { PeriodicTaskIF* tcsTask = factory->createPeriodicTask( "TCS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); + scheduling::scheduleTmpTempSensors(tcsTask); scheduling::scheduleRtdSensors(tcsTask); sif::info << "Starting tasks.." << std::endl; diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 74221458..8c87176d 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -5,7 +5,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: - TemperatureSensorInserter(object_id_t objectId); + explicit TemperatureSensorInserter(object_id_t objectId); ReturnValue_t initialize() override; @@ -18,5 +18,5 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject MAX31865::PrimarySet max31865PlocHeatspreaderSet; MAX31865::PrimarySet max31865PlocMissionboardSet; - void noise(); + // void noise(); }; diff --git a/mission/core/scheduling.cpp b/mission/core/scheduling.cpp index fb119525..50b5e473 100644 --- a/mission/core/scheduling.cpp +++ b/mission/core/scheduling.cpp @@ -3,8 +3,22 @@ #include "fsfw/tasks/PeriodicTaskIF.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" +void scheduling::scheduleTmpTempSensors(PeriodicTaskIF* tmpTask) { + const std::array tmpIds = { + objects::TMP1075_HANDLER_TCS_0, objects::TMP1075_HANDLER_TCS_1, + objects::TMP1075_HANDLER_PLPCDU_0, objects::TMP1075_HANDLER_PLPCDU_1, + objects::TMP1075_HANDLER_IF_BOARD}; + for (const auto& tmpId : tmpIds) { + tmpTask->addComponent(tmpId, DeviceHandlerIF::PERFORM_OPERATION); + tmpTask->addComponent(tmpId, DeviceHandlerIF::SEND_WRITE); + tmpTask->addComponent(tmpId, DeviceHandlerIF::GET_WRITE); + tmpTask->addComponent(tmpId, DeviceHandlerIF::SEND_READ); + tmpTask->addComponent(tmpId, DeviceHandlerIF::GET_READ); + } +} + void scheduling::scheduleRtdSensors(PeriodicTaskIF* tcsTask) { - std::array rtdIds = { + const std::array rtdIds = { objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::RTD_1_IC4_PLOC_MISSIONBOARD, objects::RTD_2_IC5_4K_CAMERA, diff --git a/mission/core/scheduling.h b/mission/core/scheduling.h index d6f68288..6023d5df 100644 --- a/mission/core/scheduling.h +++ b/mission/core/scheduling.h @@ -4,7 +4,8 @@ class PeriodicTaskIF; namespace scheduling { +void scheduleTmpTempSensors(PeriodicTaskIF* tmpSensors); void scheduleRtdSensors(PeriodicTaskIF* periodicTask); -} +} // namespace scheduling #endif // EIVE_OBSW_SCHEDULING_H From f376c01e023ef81074d92233e0acff72bca05e30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:49:25 +0100 Subject: [PATCH 17/59] fix double scheduled components --- bsp_hosted/scheduling.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index ef73cdaf..5be4429a 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -139,10 +139,6 @@ void scheduling::initTasks() { PeriodicTaskIF* thermalTask = factory->createPeriodicTask( "THERMAL_CTL_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - result = thermalTask->addComponent(objects::RTD_0_IC3_PLOC_HEATSPREADER); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("RTD_0_dummy", objects::RTD_0_IC3_PLOC_HEATSPREADER); - } result = thermalTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF); if (result != returnvalue::OK) { scheduling::printAddObjectError("SUS_0_dummy", objects::SUS_0_N_LOC_XFYFZM_PT_XF); From 41eefda1bc7068b1c171694212bc01c49b64fd88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 10:53:26 +0100 Subject: [PATCH 18/59] move obj ID --- bsp_hosted/fsfwconfig/objects/systemObjectList.h | 1 - common/config/eive/objects.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index a1f9c20b..539ef0d9 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -25,7 +25,6 @@ enum sourceObjects : uint32_t { ARDUINO_COM_IF = 0x49000001, DUMMY_COM_IF = 0x49000002, - THERMAL_TEMP_INSERTER = 0x49000003, }; } diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 01aa1cf1..09bb0fa5 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -143,6 +143,9 @@ enum commonObjects : uint32_t { CFDP_TM_FUNNEL = 0x73000102, CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, + + // Other stuff + THERMAL_TEMP_INSERTER = 0x90000003, }; } From 44aae183112cf4578c162fbe77d32adc4f101575 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Nov 2022 11:01:06 +0100 Subject: [PATCH 19/59] q7s compiles again --- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 17 +++-------------- bsp_q7s/core/ObjectFactory.h | 4 +++- bsp_q7s/fmObjectFactory.cpp | 5 +++-- linux/ObjectFactory.cpp | 7 +++++++ mission/core/GenericFactory.cpp | 6 +++++- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 348f85f0..12733ad9 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -203,7 +203,7 @@ void initmission::initTasks() { PeriodicTaskIF* tcsTask = factory->createPeriodicTask( "TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - scheduling::scheduleTempSensors(tcsTask); + scheduling::scheduleRtdSensors(tcsTask); #endif PeriodicTaskIF* tcsSystemTask = factory->createPeriodicTask( diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 85157e66..a3181992 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -496,7 +496,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo } void ObjectFactory::createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, - HealthTableIF* healthTable) { + HealthTableIF* healthTable, + HeaterHandler*& heaterHandler) { using namespace gpio; GpioCookie* heaterGpiosCookie = new GpioCookie; GpiodRegularByLineName* gpio = nullptr; @@ -539,19 +540,7 @@ void ObjectFactory::createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwi gpioIF->addGpios(heaterGpiosCookie); - HeaterHelper helper({{ - {new HealthDevice(objects::HEATER_0_PLOC_PROC_BRD, MessageQueueIF::NO_QUEUE), - gpioIds::HEATER_0}, - {new HealthDevice(objects::HEATER_1_PCDU_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_1}, - {new HealthDevice(objects::HEATER_2_ACS_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_2}, - {new HealthDevice(objects::HEATER_3_OBC_BRD, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_3}, - {new HealthDevice(objects::HEATER_4_CAMERA, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_4}, - {new HealthDevice(objects::HEATER_5_STR, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_5}, - {new HealthDevice(objects::HEATER_6_DRO, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_6}, - {new HealthDevice(objects::HEATER_7_HPA, MessageQueueIF::NO_QUEUE), gpioIds::HEATER_7}, - }}); - new HeaterHandler(objects::HEATER_HANDLER, gpioIF, helper, pwrSwitcher, - pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); + ObjectFactory::createGenericHeaterComponents(*gpioIF, *pwrSwitcher, heaterHandler); } void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher, diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index c67353c4..2661805d 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -2,6 +2,7 @@ #define BSP_Q7S_OBJECTFACTORY_H_ #include +#include #include #include #include @@ -32,7 +33,8 @@ void createTmpComponents(); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialComIF* uartComIF, PowerSwitchIF* pwrSwitcher); -void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable); +void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable, + HeaterHandler*& heaterHandler); void createImtqComponents(PowerSwitchIF* pwrSwitcher); void createBpxBatteryComponent(); void createStrComponents(PowerSwitchIF* pwrSwitcher); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index c56dcf8d..74c9d02e 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -39,7 +39,8 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); #endif - createHeaterComponents(gpioComIF, pwrSwitcher, healthTable); + HeaterHandler* heaterHandler; + createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); #if OBSW_ADD_TMP_DEVICES == 1 createTmpComponents(); #endif @@ -81,7 +82,7 @@ void ObjectFactory::produce(void* args) { #endif /* OBSW_ADD_TEST_CODE == 1 */ createMiscComponents(); - createThermalController(); + createThermalController(*heaterHandler); createAcsController(true); satsystem::init(); } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 6ca221f1..8ab6979d 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,8 +9,15 @@ #include #include #include +#include #include +#include #include +#include +#include +#include +#include +#include #include "OBSWConfig.h" #include "devConf.h" diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 21274009..5eef0531 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -22,11 +22,15 @@ #include #include #include +#include +#include +#include #include #include #include #include "OBSWConfig.h" +#include "devices/gpioIds.h" #include "eive/definitions.h" #include "fsfw/pus/Service11TelecommandScheduling.h" #include "mission/cfdp/Config.h" @@ -203,4 +207,4 @@ void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler); -} \ No newline at end of file +} From 0484daac23910840483c729f2667867a95ad73fb Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 27 Nov 2022 16:58:57 +0100 Subject: [PATCH 20/59] thermal control first draft --- mission/controller/ThermalController.cpp | 22 ++++++++++++++++++++++ mission/controller/ThermalController.h | 15 +++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 2026e851..f4ada487 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,6 +105,28 @@ void ThermalController::performControlOperation() { } // TODO: Heater control + //TODO: Hysterese offset + if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::OFF){ + if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_ON; + heaterHandler.handleSwitchOnCommand(heater::HEATER_4_CAMERA); + heater4Countdown.resetTimer(); + } + }else if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::ON){ + if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit){ + if(heater4Countdown.hasTimedOut()){ + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; + //triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA); + heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); + } + }else { + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; + heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; + heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); + }; + } } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 9cbddab1..ab8eff0a 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,6 +8,8 @@ #include #include +#include + #include "../devices/HeaterHandler.h" /** @@ -32,6 +34,7 @@ struct TempLimits { class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; + static const uint8_t NUMBER_OF_SENSORS = 16; ThermalController(object_id_t objectId, HeaterHandler& heater); @@ -50,9 +53,11 @@ class ThermalController : public ExtendedControllerBase { private: static const uint32_t DELAY = 500; + static const uint32_t OP_TIME = 1000; //TODO to be changed enum class InternalState { STARTUP, INITIAL_DELAY, READY }; + InternalState internalState = InternalState::STARTUP; HeaterHandler& heaterHandler; @@ -119,6 +124,16 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); + // Heater Countdown to make sure heater + Countdown heater0Countdown = Countdown(OP_TIME); + Countdown heater1Countdown = Countdown(OP_TIME); + Countdown heater2Countdown = Countdown(OP_TIME); + Countdown heater3Countdown = Countdown(OP_TIME); + Countdown heater4Countdown = Countdown(OP_TIME); + Countdown heater5Countdown = Countdown(OP_TIME); + Countdown heater6Countdown = Countdown(OP_TIME); + Countdown heater7Countdown = Countdown(OP_TIME); + PoolEntry tmp1075Tcs0 = PoolEntry(10.0); PoolEntry tmp1075Tcs1 = PoolEntry(10.0); PoolEntry tmp1075PlPcdu0 = PoolEntry(10.0); From 868ba0cd0381033f213cabda1d8c382c4ecf29ce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 08:56:36 +0100 Subject: [PATCH 21/59] improvements for heater handler --- mission/controller/ThermalController.cpp | 18 ++++++++++-------- mission/controller/ThermalController.h | 3 +-- mission/devices/HeaterHandler.cpp | 9 +++++++-- mission/devices/HeaterHandler.h | 8 ++++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f4ada487..aeaeb209 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,23 +105,25 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - //TODO: Hysterese offset - if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::OFF){ - if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { + // TODO: Hysterese offset + if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == + HeaterHandler::SwitchState::OFF) { + if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_ON; heaterHandler.handleSwitchOnCommand(heater::HEATER_4_CAMERA); heater4Countdown.resetTimer(); } - }else if(heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == HeaterHandler::SwitchState::ON){ - if(sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit){ - if(heater4Countdown.hasTimedOut()){ + } else if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == + HeaterHandler::SwitchState::ON) { + if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { + if (heater4Countdown.hasTimedOut()) { heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; - //triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA); + // triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA); heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); } - }else { + } else { heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index ab8eff0a..a91e531d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -53,11 +53,10 @@ class ThermalController : public ExtendedControllerBase { private: static const uint32_t DELAY = 500; - static const uint32_t OP_TIME = 1000; //TODO to be changed + static const uint32_t OP_TIME = 1000; // TODO to be changed enum class InternalState { STARTUP, INITIAL_DELAY, READY }; - InternalState internalState = InternalState::STARTUP; HeaterHandler& heaterHandler; diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 61a44de6..a2e4a451 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -321,8 +321,13 @@ HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers swi return heaterVec.at(switchNr).switchState; } -ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, ReturnValue_t onOff) { - return sendSwitchCommand(heater, onOff); +ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState switchState) { + if (switchState == SwitchState::ON) { + return sendSwitchCommand(heater, PowerSwitchIF::SWITCH_ON); + } else if (switchState == SwitchState::OFF) { + return sendSwitchCommand(heater, PowerSwitchIF::SWITCH_OFF); + } + return returnvalue::FAILED; } bool HeaterHandler::allSwitchesOff() { diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index 18bb7240..ede7c422 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -64,7 +64,10 @@ class HeaterHandler : public ExecutableObjectIF, virtual ~HeaterHandler(); protected: - ReturnValue_t switchHeater(heater::Switchers heater, ReturnValue_t onOff); + enum SwitchState : bool { ON = true, OFF = false }; + enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE }; + + ReturnValue_t switchHeater(heater::Switchers heater, SwitchState switchState); ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; @@ -96,9 +99,6 @@ class HeaterHandler : public ExecutableObjectIF, static const MessageQueueId_t NO_COMMANDER = 0; - enum SwitchState : bool { ON = true, OFF = false }; - enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE }; - /** * @brief Struct holding information about a heater command to execute. * From 32cda0f58b48b042cc1ef50995342bc175611187 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 28 Nov 2022 10:06:49 +0100 Subject: [PATCH 22/59] further development thermal controller --- fsfw | 2 +- mission/controller/ThermalController.cpp | 42 +++++++++++++----------- mission/controller/ThermalController.h | 11 +++++-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/fsfw b/fsfw index 46a1c2ba..160ff799 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 46a1c2bacea142994666b2201acf0246ba0fd0b4 +Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index aeaeb209..274be244 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -106,28 +106,30 @@ void ThermalController::performControlOperation() { // TODO: Heater control // TODO: Hysterese offset - if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == - HeaterHandler::SwitchState::OFF) { - if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_ON; - heaterHandler.handleSwitchOnCommand(heater::HEATER_4_CAMERA); - heater4Countdown.resetTimer(); - } - } else if (heaterHandler.heaterVec[heater::HEATER_4_CAMERA].switchState == - HeaterHandler::SwitchState::ON) { - if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { - if (heater4Countdown.hasTimedOut()) { - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; - // triggerEvent(HEATER_TIMEOUT, heater::HEATER_4_CAMERA); - heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); + + // 4K Camera - Heater + if (sensorTemperatures.sensor_4k_camera.isValid()) { + if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); + heater4Countdown.resetTimer(); + } + } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + if (sensorTemperatures.sensor_4k_camera.value >= cameraLimits.opLowerLimit + TEMP_OFFSET) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); } } else { - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].cmdActive = true; - heaterHandler.heaterVec[heater::HEATER_4_CAMERA].action = HeaterHandler::SET_SWITCH_OFF; - heaterHandler.handleSwitchOffCommand(heater::HEATER_4_CAMERA); - }; + if (heater4Countdown.hasTimedOut()) { + // Sensor or heater failure + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + triggerEvent(HEATER_MAX_BURNTIME_REACHED, heater::HEATER_4_CAMERA); + }; + } + } else { + if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + } + triggerEvent(INVALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index a91e531d..203f779e 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -28,7 +28,6 @@ struct TempLimits { float opUpperLimit; float nopLowerLimit; float nopUpperLimit; - // TODO define limits }; class ThermalController : public ExtendedControllerBase { @@ -52,8 +51,15 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; + static constexpr Event HEATER_MAX_BURNTIME_REACHED = MAKE_EVENT(0, severity::LOW); + static constexpr Event INVALID_SENSOR_TEMPERATURE = MAKE_EVENT(1, severity::LOW); + static const uint32_t DELAY = 500; - static const uint32_t OP_TIME = 1000; // TODO to be changed + + // TODO to be changed + static const uint32_t OP_TIME = 1000; + static const uint32_t TEMP_OFFSET = 10; enum class InternalState { STARTUP, INITIAL_DELAY, READY }; @@ -103,6 +109,7 @@ class ThermalController : public ExtendedControllerBase { SUS::SusDataset susSet11; // TempLimits + // TODO: find missing temperatures // TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); // TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); TempLimits cameraLimits = TempLimits(-40.0, -30.0, 65.0, 85.0); From ad5ee7fa44856cbfac1fc5783bf4a3d0ec7462f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 10:39:47 +0100 Subject: [PATCH 23/59] now the unittest should run --- fsfw | 2 +- test/gpio/CMakeLists.txt | 4 +--- test/testtasks/CMakeLists.txt | 4 +--- unittest/controller/testThermalController.cpp | 11 +++++++++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/fsfw b/fsfw index 160ff799..46a1c2ba 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca +Subproject commit 46a1c2bacea142994666b2201acf0246ba0fd0b4 diff --git a/test/gpio/CMakeLists.txt b/test/gpio/CMakeLists.txt index 4ba24fd5..47ced202 100644 --- a/test/gpio/CMakeLists.txt +++ b/test/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${OBSW_NAME} PUBLIC DummyGpioIF.cpp) - -target_include_directories(${OBSW_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(${LIB_EIVE_MISSION} PUBLIC DummyGpioIF.cpp) diff --git a/test/testtasks/CMakeLists.txt b/test/testtasks/CMakeLists.txt index c0d6ed09..a816e7d2 100644 --- a/test/testtasks/CMakeLists.txt +++ b/test/testtasks/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${OBSW_NAME} PUBLIC TestTask.cpp) - -target_include_directories(${OBSW_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(${LIB_EIVE_MISSION} PUBLIC TestTask.cpp) diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 976f3c4b..e5b0c050 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -8,18 +9,24 @@ #include "../../dummies/TemperatureSensorInserter.h" #include "../testEnvironment.h" +#include "mission/core/GenericFactory.h" +#include "test/gpio/DummyGpioIF.h" TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); + auto dummyGpioIF = new DummyGpioIF(); + auto dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); // TODO: Create dummy heater handler - // new HeaterHandler() + HeaterHandler* heaterHandler = nullptr; + // new ThermalController(objects::THERMAL_CONTROLLER); + ObjectFactory::createGenericHeaterComponents(*dummyGpioIF, *dummySwitcher, heaterHandler); new SusDummy(); // testEnvironment::initialize(); - ThermalController controller(THERMAL_CONTROLLER_ID); + ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler); ReturnValue_t result = controller.initialize(); REQUIRE(result == returnvalue::OK); From f8a5e04dc7a51401fc088e7c48a6b1bed2c2ea88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 11:33:07 +0100 Subject: [PATCH 24/59] bump deps --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 46a1c2ba..8eb869e0 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 46a1c2bacea142994666b2201acf0246ba0fd0b4 +Subproject commit 8eb869e073d99e257c6cc62dbf26b4d99422e9b8 diff --git a/tmtc b/tmtc index a54ae782..a47ca5c9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a54ae782d46f6f405df8e62ab80b556f971df369 +Subproject commit a47ca5c901e340f4c07bbb778dd63bb61554dbc4 From 55608f0660ed06f7ef8d10d781766227280d0a56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 11:35:28 +0100 Subject: [PATCH 25/59] that should now fix it --- linux/boardtest/I2cTestClass.h | 2 +- linux/boardtest/LibgpiodTest.h | 2 +- linux/boardtest/SpiTestClass.h | 2 +- linux/boardtest/UartTestClass.h | 2 +- test/CMakeLists.txt | 2 ++ test/{testtasks => }/TestTask.cpp | 0 test/{testtasks => }/TestTask.h | 0 test/testtasks/CMakeLists.txt | 2 +- 8 files changed, 7 insertions(+), 5 deletions(-) rename test/{testtasks => }/TestTask.cpp (100%) rename test/{testtasks => }/TestTask.h (100%) diff --git a/linux/boardtest/I2cTestClass.h b/linux/boardtest/I2cTestClass.h index 500243c5..1a578363 100644 --- a/linux/boardtest/I2cTestClass.h +++ b/linux/boardtest/I2cTestClass.h @@ -1,7 +1,7 @@ #ifndef LINUX_BOARDTEST_I2CTESTCLASS_H_ #define LINUX_BOARDTEST_I2CTESTCLASS_H_ -#include +#include #include #include diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index 4fcaffdf..f7aada07 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -5,7 +5,7 @@ #include #include -#include "TestTask.h" +#include "test/TestTask.h" /** * @brief Test for the GPIO read implementation of the LinuxLibgpioIF. diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index dad42f4d..cdecd7f8 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 05776bc0..b206de53 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -12,7 +12,7 @@ #include "lwgps/lwgps.h" #include "mission/devices/devicedefinitions/ScexDefinitions.h" -#include "test/testtasks/TestTask.h" +#include "test/TestTask.h" class ScexUartReader; class ScexDleParser; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aea49d86..25f91941 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,2 +1,4 @@ add_subdirectory(testtasks) add_subdirectory(gpio) + +target_sources(${LIB_EIVE_MISSION} PUBLIC TestTask.cpp) diff --git a/test/testtasks/TestTask.cpp b/test/TestTask.cpp similarity index 100% rename from test/testtasks/TestTask.cpp rename to test/TestTask.cpp diff --git a/test/testtasks/TestTask.h b/test/TestTask.h similarity index 100% rename from test/testtasks/TestTask.h rename to test/TestTask.h diff --git a/test/testtasks/CMakeLists.txt b/test/testtasks/CMakeLists.txt index a816e7d2..e48d3e45 100644 --- a/test/testtasks/CMakeLists.txt +++ b/test/testtasks/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PUBLIC TestTask.cpp) +target_sources(${LIB_EIVE_MISSION} PUBLIC) From d81ae3c35fc476bcbce4c58789f8da182c7da9ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 11:46:06 +0100 Subject: [PATCH 26/59] include fix --- bsp_q7s/boardtest/Q7STestTask.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index dcfc3e96..9ba00c06 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -3,7 +3,7 @@ #include -#include "test/testtasks/TestTask.h" +#include "test/TestTask.h" class CoreController; From 4a404835c0e344f04e9c4ff013043f8493a13596 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 28 Nov 2022 17:40:29 +0100 Subject: [PATCH 27/59] further development thermal controller --- mission/controller/ThermalController.cpp | 52 +++++++++++++----------- mission/controller/ThermalController.h | 2 + 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 274be244..fc6a6088 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -106,31 +106,8 @@ void ThermalController::performControlOperation() { // TODO: Heater control // TODO: Hysterese offset + ctrl4KCameraHeater(); - // 4K Camera - Heater - if (sensorTemperatures.sensor_4k_camera.isValid()) { - if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); - heater4Countdown.resetTimer(); - } - } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - if (sensorTemperatures.sensor_4k_camera.value >= cameraLimits.opLowerLimit + TEMP_OFFSET) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - } - } else { - if (heater4Countdown.hasTimedOut()) { - // Sensor or heater failure - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - triggerEvent(HEATER_MAX_BURNTIME_REACHED, heater::HEATER_4_CAMERA); - }; - } - } else { - if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - } - triggerEvent(INVALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); - } } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -977,3 +954,30 @@ void ThermalController::copyDevices() { } } } + +void ThermalController::ctrl4KCameraHeater(){ + // 4K Camera - Heater + if (sensorTemperatures.sensor_4k_camera.isValid()) { + if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); + heater4Countdown.resetTimer(); + } + } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + if (sensorTemperatures.sensor_4k_camera.value >= cameraLimits.opLowerLimit + TEMP_OFFSET) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + } + } else { + if (heater4Countdown.hasTimedOut()) { + // Sensor or heater failure + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + triggerEvent(HEATER_MAX_BURNTIME_REACHED, heater::HEATER_4_CAMERA); + }; + } + } else { + if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + } + triggerEvent(INVALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 203f779e..076956e8 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -150,6 +150,8 @@ class ThermalController : public ExtendedControllerBase { void copySensors(); void copySus(); void copyDevices(); + + void ctrl4KCameraHeater(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ From a0dd3f585b03e4e0faa47437b3dfb26e4d138551 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Dec 2022 16:23:16 +0100 Subject: [PATCH 28/59] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 6e152818..56d0f26c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6e152818707c7a12be8900bc239a0073053c0bec +Subproject commit 56d0f26cbffbfbf4e790d3a19858162291104934 From 2b2b14193f0d9da566df66b9cfbdb67a23a07f57 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Dec 2022 18:08:49 +0100 Subject: [PATCH 29/59] fix merge conflicts --- bsp_hosted/scheduling.cpp | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 469d7f38..ba393e3a 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -185,14 +185,10 @@ void scheduling::initTasks() { } #endif /* OBSW_ADD_TEST_CODE == 1 */ -<<<<<<< HEAD - PeriodicTaskIF* tcsTask = factory->createPeriodicTask( - "TCS_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); - scheduling::scheduleTmpTempSensors(tcsTask); - scheduling::scheduleRtdSensors(tcsTask); -======= PeriodicTaskIF* dummyTask = factory->createPeriodicTask( "DUMMY_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + scheduling::scheduleTmpTempSensors(dummyTask); + scheduling::scheduleRtdSensors(dummyTask); dummyTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF); dummyTask->addComponent(objects::SUS_1_N_LOC_XBYFZM_PT_XB); dummyTask->addComponent(objects::SUS_2_N_LOC_XFYBZB_PT_YB); @@ -205,23 +201,6 @@ void scheduling::initTasks() { dummyTask->addComponent(objects::SUS_9_R_LOC_XBYBZB_PT_YF); dummyTask->addComponent(objects::SUS_10_N_LOC_XMYBZF_PT_ZF); dummyTask->addComponent(objects::SUS_11_R_LOC_XBYMZB_PT_ZB); - dummyTask->addComponent(objects::RTD_0_IC3_PLOC_HEATSPREADER); - dummyTask->addComponent(objects::RTD_1_IC4_PLOC_MISSIONBOARD); - dummyTask->addComponent(objects::RTD_2_IC5_4K_CAMERA); - dummyTask->addComponent(objects::RTD_3_IC6_DAC_HEATSPREADER); - dummyTask->addComponent(objects::RTD_4_IC7_STARTRACKER); - dummyTask->addComponent(objects::RTD_5_IC8_RW1_MX_MY); - dummyTask->addComponent(objects::RTD_6_IC9_DRO); - dummyTask->addComponent(objects::RTD_7_IC10_SCEX); - dummyTask->addComponent(objects::RTD_8_IC11_X8); - dummyTask->addComponent(objects::RTD_9_IC12_HPA); - dummyTask->addComponent(objects::RTD_10_IC13_PL_TX); - dummyTask->addComponent(objects::RTD_11_IC14_MPA); - dummyTask->addComponent(objects::RTD_12_IC15_ACU); - dummyTask->addComponent(objects::RTD_13_IC16_PLPCDU_HEATSPREADER); - dummyTask->addComponent(objects::RTD_14_IC17_TCS_BOARD); - dummyTask->addComponent(objects::RTD_15_IC18_IMTQ); ->>>>>>> origin/develop sif::info << "Starting tasks.." << std::endl; tmtcDistributor->startTask(); @@ -236,11 +215,7 @@ void scheduling::initTasks() { pstTask->startTask(); thermalTask->startTask(); -<<<<<<< HEAD - tcsTask->startTask(); -======= dummyTask->startTask(); ->>>>>>> origin/develop #if OBSW_ADD_PLOC_SUPERVISOR == 1 supvHelperTask->startTask(); #endif From 762ae04bb29d524d721585546a7d6692f0c4dc59 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 12 Dec 2022 20:07:54 +0100 Subject: [PATCH 30/59] missing tempLimits completed --- mission/controller/ThermalController.h | 44 +++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 076956e8..2df2097f 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -19,13 +19,15 @@ * limit is exceeded to avoid reaching NOP limit */ struct TempLimits { - TempLimits(float nopLowerLimit, float opLowerLimit, float opUpperLimit, float nopUpperLimit) + TempLimits(float nopLowerLimit, float opLowerLimit, float cutOffLimit, float opUpperLimit, float nopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), + cutOffLimit(cutOffLimit), nopLowerLimit(nopLowerLimit), nopUpperLimit(nopUpperLimit) {} float opLowerLimit; float opUpperLimit; + float cutOffLimit; float nopLowerLimit; float nopUpperLimit; }; @@ -109,23 +111,29 @@ class ThermalController : public ExtendedControllerBase { SUS::SusDataset susSet11; // TempLimits - // TODO: find missing temperatures - // TempLimits plocHeatspreaderLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - // TempLimits plocMissionBoardLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits cameraLimits = TempLimits(-40.0, -30.0, 65.0, 85.0); - TempLimits dacHeatspreaderLimits = TempLimits(-65.0, -40.0, 118.0, 150.0); - TempLimits strLimits = TempLimits(-30.0, -20.0, 70.0, 80.0); - TempLimits rw1Limits = TempLimits(-40.0, -40.0, 85.0, 85.0); - // TempLimits droLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits scexLimits = TempLimits(-60.0, -40.0, 85.0, 150.0); - // TempLimits x8Limits = TempLimits(-20.0, 70.0, -30.0, 80.0); - // TempLimits hpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - // TempLimits txModuleLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - // TempLimits mpaLimits = TempLimits(-20.0, 70.0, -30.0, 80.0); - TempLimits acuLimits = TempLimits(-55.0, -35.0, 85.0, 150.0); // TODO nopLimits - TempLimits plpcduHeatspreaderLimits = TempLimits(-65.0, -40.0, 85.0, 125.0); // TODO check - TempLimits tcsBoardLimits = TempLimits(-60.0, -40.0, 85.0, 130.0); - TempLimits magnettorquerLimits = TempLimits(-40.0, -30.0, 70.0, 80.0); // TODO nopLimits + TempLimits acsBoardLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0); + TempLimits mgtLimits = TempLimits(-40.0, -40.0, 65.0, 70.0, 70.0); + TempLimits rwLimits = TempLimits(-40.0, -40.0, 80.0, 85.0, 85.0); + TempLimits strLimits = TempLimits(-30.0, -20.0, 65.0, 70.0, 80.0); + TempLimits ifBoardLimits = TempLimits(-65.0, -40.0, 80.0, 85.0, 150.0); + 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); + 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); + TempLimits pcduPduLimits = TempLimits(-35.0, -35.0, 80.0, 85.0, 85.0); + TempLimits plPcduBoardLimits = TempLimits(-55.0, -40.0, 80.0, 85.0, 125.0); + TempLimits plocMissionBoardLimits = TempLimits(-30.0, -10.0, 40.0, 45.0, 60); + TempLimits plocProcessingBoardLimits = TempLimits(-30.0, -10.0, 40.0, 45.0, 60.0); + 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 scexBoardLimits = TempLimits(-60.0, -40.0, 80.0, 85.0, 150.0); // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); From 873bb2f79e8dfaade0531a09ecb2a1fa0822ab77 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 12 Dec 2022 21:33:12 +0100 Subject: [PATCH 31/59] new design heater control for camera body --- mission/controller/ThermalController.cpp | 50 +++++++++++++----------- mission/controller/ThermalController.h | 18 ++------- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index fc6a6088..b2845c69 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,8 +105,7 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - // TODO: Hysterese offset - ctrl4KCameraHeater(); + ctrl4KCamera(); } @@ -955,29 +954,36 @@ void ThermalController::copyDevices() { } } -void ThermalController::ctrl4KCameraHeater(){ - // 4K Camera - Heater +void ThermalController::ctrl4KCamera() { + // 4K Camera + float cameraTemp; + bool cameraTempAvailable = true; + if (sensorTemperatures.sensor_4k_camera.isValid()) { - if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - if (sensorTemperatures.sensor_4k_camera.value < cameraLimits.opLowerLimit) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); - heater4Countdown.resetTimer(); - } - } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - if (sensorTemperatures.sensor_4k_camera.value >= cameraLimits.opLowerLimit + TEMP_OFFSET) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - } - } else { - if (heater4Countdown.hasTimedOut()) { - // Sensor or heater failure - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - triggerEvent(HEATER_MAX_BURNTIME_REACHED, heater::HEATER_4_CAMERA); - }; - } + cameraTemp = sensorTemperatures.sensor_4k_camera.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + cameraTemp = sensorTemperatures.sensor_dro.value; + } else if (sensorTemperatures.sensor_mpa.isValid()) { + cameraTemp = sensorTemperatures.sensor_mpa.value; } else { if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); } - triggerEvent(INVALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); + cameraTempAvailable = false; } -} + + // TODO: include redundant heater + if (cameraTempAvailable) { + if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + // TODO: check if op or nop + if (cameraTemp < cameraLimits.opLowerLimit) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); + } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { + if (cameraTemp >= cameraLimits.opLowerLimit + TEMP_OFFSET) { + heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + } + } + } + } +} \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 2df2097f..dd60524b 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -54,14 +54,12 @@ class ThermalController : public ExtendedControllerBase { private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static constexpr Event HEATER_MAX_BURNTIME_REACHED = MAKE_EVENT(0, severity::LOW); - static constexpr Event INVALID_SENSOR_TEMPERATURE = MAKE_EVENT(1, severity::LOW); + static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::LOW); static const uint32_t DELAY = 500; // TODO to be changed - static const uint32_t OP_TIME = 1000; - static const uint32_t TEMP_OFFSET = 10; + static const uint32_t TEMP_OFFSET = 5; enum class InternalState { STARTUP, INITIAL_DELAY, READY }; @@ -138,16 +136,6 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); - // Heater Countdown to make sure heater - Countdown heater0Countdown = Countdown(OP_TIME); - Countdown heater1Countdown = Countdown(OP_TIME); - Countdown heater2Countdown = Countdown(OP_TIME); - Countdown heater3Countdown = Countdown(OP_TIME); - Countdown heater4Countdown = Countdown(OP_TIME); - Countdown heater5Countdown = Countdown(OP_TIME); - Countdown heater6Countdown = Countdown(OP_TIME); - Countdown heater7Countdown = Countdown(OP_TIME); - PoolEntry tmp1075Tcs0 = PoolEntry(10.0); PoolEntry tmp1075Tcs1 = PoolEntry(10.0); PoolEntry tmp1075PlPcdu0 = PoolEntry(10.0); @@ -159,7 +147,7 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrl4KCameraHeater(); + void ctrl4KCamera(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ From b89e440fc4a015995a42c56e20550fc36a329ead Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 10:19:28 +0100 Subject: [PATCH 32/59] added health getter function --- bsp_hosted/scheduling.cpp | 2 +- mission/controller/ThermalController.cpp | 1 - mission/controller/ThermalController.h | 3 ++- mission/devices/HeaterHandler.cpp | 9 +++++++++ mission/devices/HeaterHandler.h | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index ba393e3a..843b2892 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -186,7 +186,7 @@ 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", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); scheduling::scheduleTmpTempSensors(dummyTask); scheduling::scheduleRtdSensors(dummyTask); dummyTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b2845c69..a8c378df 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -106,7 +106,6 @@ void ThermalController::performControlOperation() { // TODO: Heater control ctrl4KCamera(); - } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index dd60524b..a6d6a3b3 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -19,7 +19,8 @@ * limit is exceeded to avoid reaching NOP limit */ struct TempLimits { - TempLimits(float nopLowerLimit, float opLowerLimit, float cutOffLimit, float opUpperLimit, float nopUpperLimit) + TempLimits(float nopLowerLimit, float opLowerLimit, float cutOffLimit, float opUpperLimit, + float nopUpperLimit) : opLowerLimit(opLowerLimit), opUpperLimit(opUpperLimit), cutOffLimit(cutOffLimit), diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index a2e4a451..8fd166f0 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -361,3 +361,12 @@ ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; } + +HasHealthIF::HealthState HeaterHandler::getHealth(heater::Switchers heater) { + auto* healthDev = heaterVec.at(heater).healthDevice; + if (healthDev != nullptr) { + MutexGuard mg(heaterMutex); + return healthDev->getHealth(); + } + return HasHealthIF::HealthState::FAULTY; +} diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index ede7c422..ac4f94f4 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -68,6 +68,8 @@ class HeaterHandler : public ExecutableObjectIF, enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE }; ReturnValue_t switchHeater(heater::Switchers heater, SwitchState switchState); + HasHealthIF::HealthState getHealth(heater::Switchers heater); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; From 0b1136ad28c8bd777dff6fe417417c7e6150eaa7 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 13 Dec 2022 12:08:53 +0100 Subject: [PATCH 33/59] changes thermal controller --- fsfw | 2 +- mission/controller/ThermalController.cpp | 127 ++++++++++++++++++----- mission/controller/ThermalController.h | 29 +++++- tmtc | 2 +- 4 files changed, 131 insertions(+), 29 deletions(-) diff --git a/fsfw b/fsfw index 05cad893..5b0ea912 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 05cad893a2b713827cf4cdc9afe49675f18afcc7 +Subproject commit 5b0ea91222a6b8efb2f4562cfecbcb735dfeedd5 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index a8c378df..008a8077 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,7 +105,7 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - ctrl4KCamera(); + ctrlCameraBody(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -953,36 +953,111 @@ void ThermalController::copyDevices() { } } -void ThermalController::ctrl4KCamera() { - // 4K Camera - float cameraTemp; +void ThermalController::ctrlMgt() { + float sensorTemp; + float opLowerLimit = mgtLimits.opLowerLimit; + float cutOffLimit = mgtLimits.cutOffLimit; + heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; + heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; bool cameraTempAvailable = true; + bool heaterAvailable = true; + bool redSwitchNrInUse = false; - if (sensorTemperatures.sensor_4k_camera.isValid()) { - cameraTemp = sensorTemperatures.sensor_4k_camera.value; - } else if (sensorTemperatures.sensor_dro.isValid()) { - cameraTemp = sensorTemperatures.sensor_dro.value; - } else if (sensorTemperatures.sensor_mpa.isValid()) { - cameraTemp = sensorTemperatures.sensor_mpa.value; - } else { - if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); + // Choose Heater + chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable); + + if (heaterAvailable) { + // Choose sensor + if (sensorTemperatures.sensor_magnettorquer.isValid()) { + sensorTemp = sensorTemperatures.sensor_magnettorquer.value; + } else if (sensorTemperatures.sensor_magnettorquer.isValid()) { // TODO: int sensor + sensorTemp = sensorTemperatures.sensor_magnettorquer.value; + } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { + sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + cameraTempAvailable = false; } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, heater::HEATER_4_CAMERA); - cameraTempAvailable = false; - } - // TODO: include redundant heater - if (cameraTempAvailable) { - if (not heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - // TODO: check if op or nop - if (cameraTemp < cameraLimits.opLowerLimit) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::ON); - } else if (heaterHandler.checkSwitchState(heater::HEATER_4_CAMERA)) { - if (cameraTemp >= cameraLimits.opLowerLimit + TEMP_OFFSET) { - heaterHandler.switchHeater(heater::HEATER_4_CAMERA, HeaterHandler::SwitchState::OFF); - } + // Thermal Control + if (cameraTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit); + } + } +} +void ThermalController::ctrlCameraBody() { + // Camera Body + float sensorTemp; + float opLowerLimit = cameraLimits.opLowerLimit; + float cutOffLimit = cameraLimits.cutOffLimit; + heater::Switchers switchNr = heater::HEATER_4_CAMERA; + heater::Switchers redSwitchNr = heater::HEATER_6_DRO; + bool cameraTempAvailable = true; + bool heaterAvailable = true; + bool redSwitchNrInUse = false; + + // Choose Heater + chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable); + + if (heaterAvailable) { + // Choose sensor + if (sensorTemperatures.sensor_4k_camera.isValid()) { + sensorTemp = sensorTemperatures.sensor_4k_camera.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + sensorTemp = sensorTemperatures.sensor_dro.value; + } else if (sensorTemperatures.sensor_mpa.isValid()) { + sensorTemp = sensorTemperatures.sensor_mpa.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + cameraTempAvailable = false; + } + + // Thermal Control + if (cameraTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit); + } + } +} + +void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + bool redSwitchNrInUse, float sensorTemp, float opLowerLimit, + float cutOffLimit) { + // Heater off + if (not heaterHandler.checkSwitchState(switchNr)) { + // TODO: check if OP or NOP + if (sensorTemp < opLowerLimit) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); + } + // Heater on + } else if (heaterHandler.checkSwitchState(switchNr)) { + if (sensorTemp >= opLowerLimit + TEMP_OFFSET) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + } else if (not redSwitchNrInUse) { + if (heaterHandler.checkSwitchState(redSwitchNr)) { + if (sensorTemp >= cutOffLimit) { + heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); } } } +} + +void ThermalController::chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + bool& redSwitchNrInUse, bool& heaterAvailable) { + // Choose Heater + if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { + if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { + switchNr = redSwitchNr; + redSwitchNrInUse = true; + } else { + heaterAvailable = false; + // TODO: triggerEvent ? + } + } } \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index a6d6a3b3..4fe61e8c 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -148,7 +148,34 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrl4KCamera(); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, bool redSwitchNrInUse, + float sensorTemp, float opLowerLimit, float cutOffLimit); + void chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + bool& redSwitchNrInUse, bool& heaterAvailable); + + void ctrlAcsBoard(); + void ctrlMgt(); + void ctrlRw(); + void ctrlStr(); + void ctrlIfBoard(); + void ctrlTcsBoard(); + void ctrlObc(); + void ctrlObcIfBoard(); + void ctrlSBandTransceiver(); + void ctrlPcduP60Board(); + void ctrlPcduAcu(); + void ctrlPcduPdu(); + void ctrlPlPcduBoard(); + void ctrlPlocMissionBoard(); + void ctrlPlocProcessingBoard(); + void ctrlDac(); + void ctrlCameraBody(); + void ctrlDro(); + void ctrlX8(); + void ctrlHpa(); + void ctrlTx(); + void ctrlMpa(); + void ctrlScexBoard(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/tmtc b/tmtc index 30cf4736..56d0f26c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 30cf47365fec68a4b78395de03ecb2ae95af4e7e +Subproject commit 56d0f26cbffbfbf4e790d3a19858162291104934 From 8a9ed28845d3854643432846b477f20f4c1052c1 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 14 Dec 2022 11:24:03 +0100 Subject: [PATCH 34/59] changes thermal control --- mission/controller/ThermalController.cpp | 93 +++++++++++------------- mission/controller/ThermalController.h | 15 +++- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 008a8077..9b68d085 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -954,80 +954,49 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlMgt() { - float sensorTemp; float opLowerLimit = mgtLimits.opLowerLimit; float cutOffLimit = mgtLimits.cutOffLimit; heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; - bool cameraTempAvailable = true; - bool heaterAvailable = true; - bool redSwitchNrInUse = false; - // Choose Heater - chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable); + chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - // Choose sensor - if (sensorTemperatures.sensor_magnettorquer.isValid()) { - sensorTemp = sensorTemperatures.sensor_magnettorquer.value; - } else if (sensorTemperatures.sensor_magnettorquer.isValid()) { // TODO: int sensor - sensorTemp = sensorTemperatures.sensor_magnettorquer.value; - } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { - sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - cameraTempAvailable = false; - } + chooseSensor(switchNr, sensorTemperatures.sensor_magnettorquer.value, + sensorTemperatures.sensor_magnettorquer.value, + sensorTemperatures.sensor_plpcdu_heatspreader.value, + sensorTemperatures.sensor_magnettorquer.isValid(), + sensorTemperatures.sensor_magnettorquer.isValid(), + sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); // TODO: int sensor - // Thermal Control - if (cameraTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit); + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit); } } } void ThermalController::ctrlCameraBody() { // Camera Body - float sensorTemp; float opLowerLimit = cameraLimits.opLowerLimit; float cutOffLimit = cameraLimits.cutOffLimit; heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; - bool cameraTempAvailable = true; - bool heaterAvailable = true; - bool redSwitchNrInUse = false; - // Choose Heater - chooseHeater(switchNr, redSwitchNr, redSwitchNrInUse, heaterAvailable); + chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - // Choose sensor - if (sensorTemperatures.sensor_4k_camera.isValid()) { - sensorTemp = sensorTemperatures.sensor_4k_camera.value; - } else if (sensorTemperatures.sensor_dro.isValid()) { - sensorTemp = sensorTemperatures.sensor_dro.value; - } else if (sensorTemperatures.sensor_mpa.isValid()) { - sensorTemp = sensorTemperatures.sensor_mpa.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - cameraTempAvailable = false; - } + chooseSensor(switchNr, sensorTemperatures.sensor_4k_camera.value, + sensorTemperatures.sensor_dro.value, sensorTemperatures.sensor_mpa.value, + sensorTemperatures.sensor_4k_camera.isValid(), + sensorTemperatures.sensor_dro.isValid(), sensorTemperatures.sensor_mpa.isValid()); - // Thermal Control - if (cameraTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, redSwitchNrInUse, sensorTemp, opLowerLimit, cutOffLimit); + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit); } } } void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - bool redSwitchNrInUse, float sensorTemp, float opLowerLimit, - float cutOffLimit) { + float opLowerLimit, float cutOffLimit) { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { // TODO: check if OP or NOP @@ -1048,9 +1017,10 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers } } -void ThermalController::chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - bool& redSwitchNrInUse, bool& heaterAvailable) { +void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { // Choose Heater + heaterAvailable = true; + if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { switchNr = redSwitchNr; @@ -1059,5 +1029,28 @@ void ThermalController::chooseHeater(heater::Switchers switchNr, heater::Switche heaterAvailable = false; // TODO: triggerEvent ? } + } else { + redSwitchNrInUse = false; + } +} + +void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorValue1, + float sensorValue2, float sensorValue3, bool sensor1Valid, + bool sensor2Valid, bool sensor3Valid) { + // Choose sensor + sensorTempAvailable = true; + + if (sensor1Valid) { + sensorTemp = sensorValue1; + } else if (sensor2Valid) { + sensorTemp = sensorValue2; + } else if (sensor3Valid) { + sensorTemp = sensorValue3; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; } } \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 4fe61e8c..ed765278 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -134,6 +134,11 @@ class ThermalController : public ExtendedControllerBase { 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); + float sensorTemp; + bool sensorTempAvailable = true; + bool heaterAvailable = true; + bool redSwitchNrInUse = false; + // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); @@ -144,14 +149,16 @@ class ThermalController : public ExtendedControllerBase { PoolEntry tmp1075IfBrd = PoolEntry(10.0); static constexpr dur_millis_t MUTEX_TIMEOUT = 50; + void copySensors(); void copySus(); void copyDevices(); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, bool redSwitchNrInUse, - float sensorTemp, float opLowerLimit, float cutOffLimit); - void chooseHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - bool& redSwitchNrInUse, bool& heaterAvailable); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, float opLowerLimit, + float cutOffLimit); + void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); + void chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2, + float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); void ctrlAcsBoard(); void ctrlMgt(); From 6365f497a7396fdca23b6d9f7d5de2364396f961 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 19 Dec 2022 10:51:31 +0100 Subject: [PATCH 35/59] changes thermal control --- mission/controller/ThermalController.cpp | 107 +++++++++++++++++++---- mission/controller/ThermalController.h | 3 +- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 9b68d085..bcb448a0 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,7 +105,29 @@ void ThermalController::performControlOperation() { } // TODO: Heater control + ctrlAcsBoard(); + ctrlMgt(); + ctrlRw(); + ctrlStr(); + ctrlIfBoard(); + ctrlTcsBoard(); + ctrlObc(); + ctrlObcIfBoard(); + ctrlSBandTransceiver(); + ctrlPcduP60Board(); + ctrlPcduAcu(); + ctrlPcduPdu(); + ctrlPlPcduBoard(); + ctrlPlocMissionBoard(); + ctrlPlocProcessingBoard(); + ctrlDac(); ctrlCameraBody(); + ctrlDro(); + ctrlX8(); + ctrlHpa(); + ctrlTx(); + ctrlMpa(); + ctrlScexBoard(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -953,9 +975,8 @@ void ThermalController::copyDevices() { } } +void ThermalController::ctrlAcsBoard() {} void ThermalController::ctrlMgt() { - float opLowerLimit = mgtLimits.opLowerLimit; - float cutOffLimit = mgtLimits.cutOffLimit; heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; @@ -963,21 +984,70 @@ void ThermalController::ctrlMgt() { if (heaterAvailable) { chooseSensor(switchNr, sensorTemperatures.sensor_magnettorquer.value, - sensorTemperatures.sensor_magnettorquer.value, + deviceTemperatures.mgt.value, sensorTemperatures.sensor_plpcdu_heatspreader.value, sensorTemperatures.sensor_magnettorquer.isValid(), - sensorTemperatures.sensor_magnettorquer.isValid(), - sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); // TODO: int sensor + deviceTemperatures.mgt.isValid(), + sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit); + ctrlHeater(switchNr, redSwitchNr, &mgtLimits); } } } + +void ThermalController::ctrlRw() {} + +void ThermalController::ctrlStr() { + heater::Switchers switchNr = heater::HEATER_5_STR; + heater::Switchers redSwitchNr = heater::HEATER_6_DRO; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + chooseSensor(switchNr, sensorTemperatures.sensor_startracker.value, + deviceTemperatures.startracker.value, + sensorTemperatures.sensor_dro.value, + sensorTemperatures.sensor_startracker.isValid(), + deviceTemperatures.startracker.isValid(), + sensorTemperatures.sensor_dro.isValid()); + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &strLimits); + } + } +} +void ThermalController::ctrlIfBoard() { + heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; + heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + chooseSensor(switchNr, sensorTemperatures.tmp1075IfBrd.value, + sensorTemperatures.sensor_magnettorquer.value, + deviceTemperatures.mgm2SideB.value, + sensorTemperatures.tmp1075IfBrd.isValid(), + sensorTemperatures.sensor_magnettorquer.isValid(), + deviceTemperatures.mgm2SideB.isValid()); + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &ifBoardLimits); + } + } +} +void ThermalController::ctrlTcsBoard() {} +void ThermalController::ctrlObc() {} +void ThermalController::ctrlObcIfBoard() {} +void ThermalController::ctrlSBandTransceiver() {} +void ThermalController::ctrlPcduP60Board() {} +void ThermalController::ctrlPcduAcu() {} +void ThermalController::ctrlPcduPdu() {} +void ThermalController::ctrlPlPcduBoard() {} +void ThermalController::ctrlPlocMissionBoard() {} +void ThermalController::ctrlPlocProcessingBoard() {} +void ThermalController::ctrlDac() {} void ThermalController::ctrlCameraBody() { - // Camera Body - float opLowerLimit = cameraLimits.opLowerLimit; - float cutOffLimit = cameraLimits.cutOffLimit; heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; @@ -990,27 +1060,33 @@ void ThermalController::ctrlCameraBody() { sensorTemperatures.sensor_dro.isValid(), sensorTemperatures.sensor_mpa.isValid()); if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, opLowerLimit, cutOffLimit); + ctrlHeater(switchNr, redSwitchNr, &cameraLimits); } } } -void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - float opLowerLimit, float cutOffLimit) { +void ThermalController::ctrlDro() {} +void ThermalController::ctrlX8() {} +void ThermalController::ctrlHpa() {} +void ThermalController::ctrlTx() {} +void ThermalController::ctrlMpa() {} +void ThermalController::ctrlScexBoard() {} + +void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits *tempLimit) { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { // TODO: check if OP or NOP - if (sensorTemp < opLowerLimit) { + if (sensorTemp < (*tempLimit).opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); } // Heater on } else if (heaterHandler.checkSwitchState(switchNr)) { - if (sensorTemp >= opLowerLimit + TEMP_OFFSET) { + if (sensorTemp >= (*tempLimit).opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); } } else if (not redSwitchNrInUse) { if (heaterHandler.checkSwitchState(redSwitchNr)) { - if (sensorTemp >= cutOffLimit) { + if (sensorTemp >= (*tempLimit).cutOffLimit) { heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); } } @@ -1037,7 +1113,6 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2, float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid) { - // Choose sensor sensorTempAvailable = true; if (sensor1Valid) { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index ed765278..3094b8de 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -154,8 +154,7 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, float opLowerLimit, - float cutOffLimit); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits *tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2, float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); From 8bfe2405cdd56b3fa5d5bcc4151260c76509fa89 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 19 Dec 2022 18:30:22 +0100 Subject: [PATCH 36/59] changes thermal control --- mission/controller/ThermalController.cpp | 115 ++++++++++++++++++----- mission/controller/ThermalController.h | 4 +- 2 files changed, 95 insertions(+), 24 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index bcb448a0..53530634 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -975,7 +975,9 @@ void ThermalController::copyDevices() { } } -void ThermalController::ctrlAcsBoard() {} +void ThermalController::ctrlAcsBoard() { + ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, &acsBoardLimits); +} void ThermalController::ctrlMgt() { heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; @@ -984,8 +986,7 @@ void ThermalController::ctrlMgt() { if (heaterAvailable) { chooseSensor(switchNr, sensorTemperatures.sensor_magnettorquer.value, - deviceTemperatures.mgt.value, - sensorTemperatures.sensor_plpcdu_heatspreader.value, + deviceTemperatures.mgt.value, sensorTemperatures.sensor_plpcdu_heatspreader.value, sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgt.isValid(), sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); @@ -996,7 +997,9 @@ void ThermalController::ctrlMgt() { } } -void ThermalController::ctrlRw() {} +void ThermalController::ctrlRw() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, &rwLimits); +} void ThermalController::ctrlStr() { heater::Switchers switchNr = heater::HEATER_5_STR; @@ -1006,11 +1009,9 @@ void ThermalController::ctrlStr() { if (heaterAvailable) { chooseSensor(switchNr, sensorTemperatures.sensor_startracker.value, - deviceTemperatures.startracker.value, - sensorTemperatures.sensor_dro.value, + deviceTemperatures.startracker.value, sensorTemperatures.sensor_dro.value, sensorTemperatures.sensor_startracker.isValid(), - deviceTemperatures.startracker.isValid(), - sensorTemperatures.sensor_dro.isValid()); + deviceTemperatures.startracker.isValid(), sensorTemperatures.sensor_dro.isValid()); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &strLimits); @@ -1025,8 +1026,7 @@ void ThermalController::ctrlIfBoard() { if (heaterAvailable) { chooseSensor(switchNr, sensorTemperatures.tmp1075IfBrd.value, - sensorTemperatures.sensor_magnettorquer.value, - deviceTemperatures.mgm2SideB.value, + sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgm2SideB.value, sensorTemperatures.tmp1075IfBrd.isValid(), sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgm2SideB.isValid()); @@ -1036,17 +1036,71 @@ void ThermalController::ctrlIfBoard() { } } } -void ThermalController::ctrlTcsBoard() {} -void ThermalController::ctrlObc() {} -void ThermalController::ctrlObcIfBoard() {} -void ThermalController::ctrlSBandTransceiver() {} -void ThermalController::ctrlPcduP60Board() {} -void ThermalController::ctrlPcduAcu() {} -void ThermalController::ctrlPcduPdu() {} -void ThermalController::ctrlPlPcduBoard() {} -void ThermalController::ctrlPlocMissionBoard() {} -void ThermalController::ctrlPlocProcessingBoard() {} -void ThermalController::ctrlDac() {} +void ThermalController::ctrlTcsBoard() { + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &tcsBoardLimits); +} +void ThermalController::ctrlObc() { + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcLimits); +} +void ThermalController::ctrlObcIfBoard() { + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcIfBoardLimits); +} +void ThermalController::ctrlSBandTransceiver() { + ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, &sBandTransceiverLimits); +} +void ThermalController::ctrlPcduP60Board() { + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduP60BoardLimits); +} +void ThermalController::ctrlPcduAcu() { + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduAcuLimits); +} +void ThermalController::ctrlPcduPdu() { + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduPduLimits); +} +void ThermalController::ctrlPlPcduBoard() { + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &plPcduBoardLimits); +} +void ThermalController::ctrlPlocMissionBoard() { + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, &plocMissionBoardLimits); +} +void ThermalController::ctrlPlocProcessingBoard() { + heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; + heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + chooseSensor(switchNr, sensorTemperatures.sensor_ploc_missionboard.value, + sensorTemperatures.sensor_ploc_heatspreader.value, + sensorTemperatures.sensor_dac_heatspreader.value, + sensorTemperatures.sensor_ploc_missionboard.isValid(), + sensorTemperatures.sensor_ploc_heatspreader.isValid(), + sensorTemperatures.sensor_dac_heatspreader.isValid()); + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &plocProcessingBoardLimits); + } + } +} +void ThermalController::ctrlDac() { + heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; + heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + chooseSensor(switchNr, sensorTemperatures.sensor_dac_heatspreader.value, + sensorTemperatures.sensor_ploc_missionboard.value, + sensorTemperatures.sensor_ploc_heatspreader.value, + sensorTemperatures.sensor_dac_heatspreader.isValid(), + sensorTemperatures.sensor_ploc_missionboard.isValid(), + sensorTemperatures.sensor_ploc_heatspreader.isValid()); + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &dacLimits); + } + } +} void ThermalController::ctrlCameraBody() { heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; @@ -1072,7 +1126,8 @@ void ThermalController::ctrlTx() {} void ThermalController::ctrlMpa() {} void ThermalController::ctrlScexBoard() {} -void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits *tempLimit) { +void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + struct TempLimits* tempLimit) { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { // TODO: check if OP or NOP @@ -1128,4 +1183,18 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorVal triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; } -} \ No newline at end of file +} + +void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits *tempLimit) { + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + //chooseSensor(); //TODO + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, tempLimit); + } + } +} + diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 3094b8de..35707ff5 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -154,7 +154,9 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits *tempLimit); + void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits *tempLimit); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, + struct TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2, float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); From 20fd204aa93b1e8859ff6859d6bc3329a82e3fbd Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 19 Dec 2022 18:45:08 +0100 Subject: [PATCH 37/59] changes thermal control --- mission/controller/ThermalController.cpp | 61 ++++++++++++++++++------ mission/controller/ThermalController.h | 3 +- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 53530634..d0456c54 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -978,6 +978,7 @@ void ThermalController::copyDevices() { void ThermalController::ctrlAcsBoard() { ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, &acsBoardLimits); } + void ThermalController::ctrlMgt() { heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; @@ -1018,6 +1019,7 @@ void ThermalController::ctrlStr() { } } } + void ThermalController::ctrlIfBoard() { heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; @@ -1036,33 +1038,45 @@ void ThermalController::ctrlIfBoard() { } } } + void ThermalController::ctrlTcsBoard() { ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &tcsBoardLimits); } + void ThermalController::ctrlObc() { ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcLimits); } + void ThermalController::ctrlObcIfBoard() { ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcIfBoardLimits); } + void ThermalController::ctrlSBandTransceiver() { - ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, &sBandTransceiverLimits); + ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, + &sBandTransceiverLimits); } void ThermalController::ctrlPcduP60Board() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduP60BoardLimits); + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, + &pcduP60BoardLimits); } + void ThermalController::ctrlPcduAcu() { ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduAcuLimits); } + void ThermalController::ctrlPcduPdu() { ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduPduLimits); } + void ThermalController::ctrlPlPcduBoard() { ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &plPcduBoardLimits); } + void ThermalController::ctrlPlocMissionBoard() { - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, &plocMissionBoardLimits); + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, + &plocMissionBoardLimits); } + void ThermalController::ctrlPlocProcessingBoard() { heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; @@ -1082,6 +1096,7 @@ void ThermalController::ctrlPlocProcessingBoard() { } } } + void ThermalController::ctrlDac() { heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; @@ -1101,6 +1116,7 @@ void ThermalController::ctrlDac() { } } } + void ThermalController::ctrlCameraBody() { heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; @@ -1119,12 +1135,29 @@ void ThermalController::ctrlCameraBody() { } } -void ThermalController::ctrlDro() {} -void ThermalController::ctrlX8() {} -void ThermalController::ctrlHpa() {} -void ThermalController::ctrlTx() {} -void ThermalController::ctrlMpa() {} -void ThermalController::ctrlScexBoard() {} +void ThermalController::ctrlDro() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits); +} + +void ThermalController::ctrlX8() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &x8Limits); +} + +void ThermalController::ctrlTx() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &txLimits); +} + +void ThermalController::ctrlMpa() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &mpaLimits); +} + +void ThermalController::ctrlHpa() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &hpaLimits); +} + +void ThermalController::ctrlScexBoard() { + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, &scexBoardLimits); +} void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit) { @@ -1185,16 +1218,16 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorVal } } -void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits *tempLimit) { - +void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, + heater::Switchers redSwitchNr, + TempLimits* tempLimit) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - //chooseSensor(); //TODO + // chooseSensor(); //TODO if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); } } -} - +} \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 35707ff5..874297fd 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -154,7 +154,8 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits *tempLimit); + void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, + TempLimits* tempLimit); void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); From bac8166611090c85c9ce71bb9e477a884c4c8ed0 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 20 Dec 2022 15:47:40 +0100 Subject: [PATCH 38/59] changes thermal control --- mission/controller/ThermalController.cpp | 17 ++++++++++------- mission/controller/ThermalController.h | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index d0456c54..380b70cf 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,7 +105,8 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - ctrlAcsBoard(); + ctrlCameraBody(); + /*ctrlAcsBoard(); ctrlMgt(); ctrlRw(); ctrlStr(); @@ -121,13 +122,13 @@ void ThermalController::performControlOperation() { ctrlPlocMissionBoard(); ctrlPlocProcessingBoard(); ctrlDac(); - ctrlCameraBody(); + ctrlDro(); ctrlX8(); ctrlHpa(); ctrlTx(); ctrlMpa(); - ctrlScexBoard(); + ctrlScexBoard();*/ } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -1121,7 +1122,7 @@ void ThermalController::ctrlCameraBody() { heater::Switchers switchNr = heater::HEATER_4_CAMERA; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; - chooseHeater(switchNr, redSwitchNr); + //chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { chooseSensor(switchNr, sensorTemperatures.sensor_4k_camera.value, @@ -1130,7 +1131,7 @@ void ThermalController::ctrlCameraBody() { sensorTemperatures.sensor_dro.isValid(), sensorTemperatures.sensor_mpa.isValid()); if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &cameraLimits); + //ctrlHeater(switchNr, redSwitchNr, &cameraLimits); } } } @@ -1191,7 +1192,8 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch redSwitchNrInUse = true; } else { heaterAvailable = false; - // TODO: triggerEvent ? + //TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + sif::error << "ThermalController::chooseSensor: Both heater: "<< switchNr << " + " << redSwitchNr << " not healthy" << std::endl; } } else { redSwitchNrInUse = false; @@ -1213,7 +1215,8 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorVal if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + //TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl; sensorTempAvailable = false; } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 874297fd..5611b67f 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -55,7 +55,8 @@ class ThermalController : public ExtendedControllerBase { private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(0, severity::LOW); + static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(8, severity::MEDIUM); + static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(9, severity::MEDIUM); static const uint32_t DELAY = 500; From 23906047ec28f963d7f6a76f41550d61df5cb9fe Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 4 Jan 2023 17:30:17 +0100 Subject: [PATCH 39/59] thermal control changes --- mission/controller/ThermalController.cpp | 59 +++++++++++++----------- mission/controller/ThermalController.h | 5 +- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 380b70cf..538f6434 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -976,6 +976,7 @@ void ThermalController::copyDevices() { } } +/* void ThermalController::ctrlAcsBoard() { ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, &acsBoardLimits); } @@ -987,7 +988,7 @@ void ThermalController::ctrlMgt() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.sensor_magnettorquer.value, + chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgt.value, sensorTemperatures.sensor_plpcdu_heatspreader.value, sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgt.isValid(), @@ -1010,7 +1011,7 @@ void ThermalController::ctrlStr() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.sensor_startracker.value, + chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_startracker.value, deviceTemperatures.startracker.value, sensorTemperatures.sensor_dro.value, sensorTemperatures.sensor_startracker.isValid(), deviceTemperatures.startracker.isValid(), sensorTemperatures.sensor_dro.isValid()); @@ -1028,7 +1029,7 @@ void ThermalController::ctrlIfBoard() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.tmp1075IfBrd.value, + chooseSensorOldVersion(switchNr, sensorTemperatures.tmp1075IfBrd.value, sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgm2SideB.value, sensorTemperatures.tmp1075IfBrd.isValid(), sensorTemperatures.sensor_magnettorquer.isValid(), @@ -1085,7 +1086,7 @@ void ThermalController::ctrlPlocProcessingBoard() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.sensor_ploc_missionboard.value, + chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_ploc_missionboard.value, sensorTemperatures.sensor_ploc_heatspreader.value, sensorTemperatures.sensor_dac_heatspreader.value, sensorTemperatures.sensor_ploc_missionboard.isValid(), @@ -1105,7 +1106,7 @@ void ThermalController::ctrlDac() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.sensor_dac_heatspreader.value, + chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_dac_heatspreader.value, sensorTemperatures.sensor_ploc_missionboard.value, sensorTemperatures.sensor_ploc_heatspreader.value, sensorTemperatures.sensor_dac_heatspreader.isValid(), @@ -1117,25 +1118,11 @@ void ThermalController::ctrlDac() { } } } - +*/ void ThermalController::ctrlCameraBody() { - heater::Switchers switchNr = heater::HEATER_4_CAMERA; - heater::Switchers redSwitchNr = heater::HEATER_6_DRO; - - //chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensor(switchNr, sensorTemperatures.sensor_4k_camera.value, - sensorTemperatures.sensor_dro.value, sensorTemperatures.sensor_mpa.value, - sensorTemperatures.sensor_4k_camera.isValid(), - sensorTemperatures.sensor_dro.isValid(), sensorTemperatures.sensor_mpa.isValid()); - - if (sensorTempAvailable) { - //ctrlHeater(switchNr, redSwitchNr, &cameraLimits); - } - } + ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro, sensorTemperatures.sensor_mpa, &cameraLimits); } - +/* void ThermalController::ctrlDro() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits); } @@ -1159,7 +1146,7 @@ void ThermalController::ctrlHpa() { void ThermalController::ctrlScexBoard() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, &scexBoardLimits); } - +*/ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit) { // Heater off @@ -1183,7 +1170,6 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers } void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { - // Choose Heater heaterAvailable = true; if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { @@ -1200,7 +1186,26 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } } -void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorValue1, +void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3) { + sensorTempAvailable = true; + + if (sensor1.isValid()) { + sensorTemp = sensor1.value; + } else if (sensor2.isValid()) { + sensorTemp = sensor2.value; + } else if (sensor3.isValid()) { + sensorTemp = sensor3.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + //TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl; + sensorTempAvailable = false; + } +} + +void ThermalController::chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1, float sensorValue2, float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid) { sensorTempAvailable = true; @@ -1222,12 +1227,12 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, float sensorVal } void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, - heater::Switchers redSwitchNr, + heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - // chooseSensor(); //TODO + chooseSensor(switchNr, sensor1, sensor2, sensor3); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 5611b67f..7a7ef7e7 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -155,12 +155,13 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, + void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit); void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); - void chooseSensor(heater::Switchers switchNr, float sensorValue1, float sensorValue2, + void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3); + void chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1, float sensorValue2, float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); void ctrlAcsBoard(); From a81e7c5057811d9ea63bdfcdf39df4db563d843c Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 4 Jan 2023 19:03:01 +0100 Subject: [PATCH 40/59] thermal control chooseSensor() changes --- mission/controller/ThermalController.cpp | 154 ++++++++--------------- mission/controller/ThermalController.h | 13 +- 2 files changed, 57 insertions(+), 110 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 538f6434..c1e3cf71 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,7 +105,7 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - ctrlCameraBody(); + //ctrlCameraBody(); /*ctrlAcsBoard(); ctrlMgt(); ctrlRw(); @@ -978,7 +978,10 @@ void ThermalController::copyDevices() { /* void ThermalController::ctrlAcsBoard() { - ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, &acsBoardLimits); + ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, + deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, + &acsBoardLimits); // TODO: add red sensors } void ThermalController::ctrlMgt() { @@ -988,11 +991,11 @@ void ThermalController::ctrlMgt() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_magnettorquer.value, - deviceTemperatures.mgt.value, sensorTemperatures.sensor_plpcdu_heatspreader.value, - sensorTemperatures.sensor_magnettorquer.isValid(), - deviceTemperatures.mgt.isValid(), - sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); + chooseSensorOldVersion( + switchNr, sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgt.value, + sensorTemperatures.sensor_plpcdu_heatspreader.value, + sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgt.isValid(), + sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &mgtLimits); @@ -1001,44 +1004,20 @@ void ThermalController::ctrlMgt() { } void ThermalController::ctrlRw() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, &rwLimits); + // ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, + // sensorTemperatures.sensor_rw1, deviceTemperatures.rw1, deviceTemperatures.rw3, &rwLimits); } void ThermalController::ctrlStr() { - heater::Switchers switchNr = heater::HEATER_5_STR; - heater::Switchers redSwitchNr = heater::HEATER_6_DRO; - - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_startracker.value, - deviceTemperatures.startracker.value, sensorTemperatures.sensor_dro.value, - sensorTemperatures.sensor_startracker.isValid(), - deviceTemperatures.startracker.isValid(), sensorTemperatures.sensor_dro.isValid()); - - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &strLimits); - } - } + ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, + sensorTemperatures.sensor_startracker, deviceTemperatures.startracker, + sensorTemperatures.sensor_dro, &strLimits); } void ThermalController::ctrlIfBoard() { - heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; - heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; - - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensorOldVersion(switchNr, sensorTemperatures.tmp1075IfBrd.value, - sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgm2SideB.value, - sensorTemperatures.tmp1075IfBrd.isValid(), - sensorTemperatures.sensor_magnettorquer.isValid(), - deviceTemperatures.mgm2SideB.isValid()); - - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &ifBoardLimits); - } - } + ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, + sensorTemperatures.tmp1075IfBrd, sensorTemperatures.sensor_magnettorquer, + deviceTemperatures.mgm2SideB, &ifBoardLimits); } void ThermalController::ctrlTcsBoard() { @@ -1080,49 +1059,25 @@ void ThermalController::ctrlPlocMissionBoard() { } void ThermalController::ctrlPlocProcessingBoard() { - heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; - heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; - - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_ploc_missionboard.value, - sensorTemperatures.sensor_ploc_heatspreader.value, - sensorTemperatures.sensor_dac_heatspreader.value, - sensorTemperatures.sensor_ploc_missionboard.isValid(), - sensorTemperatures.sensor_ploc_heatspreader.isValid(), - sensorTemperatures.sensor_dac_heatspreader.isValid()); - - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &plocProcessingBoardLimits); - } - } + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, + sensorTemperatures.sensor_ploc_missionboard, + sensorTemperatures.sensor_ploc_heatspreader, + sensorTemperatures.sensor_dac_heatspreader, &plocProcessingBoardLimits); } void ThermalController::ctrlDac() { - heater::Switchers switchNr = heater::HEATER_1_PLOC_PROC_BRD; - heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; - - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensorOldVersion(switchNr, sensorTemperatures.sensor_dac_heatspreader.value, - sensorTemperatures.sensor_ploc_missionboard.value, - sensorTemperatures.sensor_ploc_heatspreader.value, - sensorTemperatures.sensor_dac_heatspreader.isValid(), - sensorTemperatures.sensor_ploc_missionboard.isValid(), - sensorTemperatures.sensor_ploc_heatspreader.isValid()); - - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &dacLimits); - } - } + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, + sensorTemperatures.sensor_dac_heatspreader, + sensorTemperatures.sensor_ploc_missionboard, + sensorTemperatures.sensor_ploc_heatspreader, &dacLimits); } -*/ + void ThermalController::ctrlCameraBody() { - ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro, sensorTemperatures.sensor_mpa, &cameraLimits); + ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, + sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro, + sensorTemperatures.sensor_mpa, &cameraLimits); } -/* + void ThermalController::ctrlDro() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits); } @@ -1178,15 +1133,19 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch redSwitchNrInUse = true; } else { heaterAvailable = false; - //TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); - sif::error << "ThermalController::chooseSensor: Both heater: "<< switchNr << " + " << redSwitchNr << " not healthy" << std::endl; + // TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + sif::error << "ThermalController::chooseSensor: Both heater: " << switchNr << " + " + << redSwitchNr << " not healthy" << std::endl; } } else { redSwitchNrInUse = false; } } -void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3) { +void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, + const lp_float_t& sensor4, const lp_float_t& sensor5, + bool moreThan3Sensors) { sensorTempAvailable = true; if (sensor1.isValid()) { @@ -1195,44 +1154,29 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ sensorTemp = sensor2.value; } else if (sensor3.isValid()) { sensorTemp = sensor3.value; + } else if (moreThan3Sensors and sensor4.isValid()) { + sensorTemp = sensor4.value; + } else if (moreThan3Sensors and sensor5.isValid()) { + sensorTemp = sensor5.value; } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); } - //TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl; + // TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sif::error << "ThermalController::chooseSensor: No valid Sensor found" << std::endl; sensorTempAvailable = false; } } -void ThermalController::chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1, - float sensorValue2, float sensorValue3, bool sensor1Valid, - bool sensor2Valid, bool sensor3Valid) { - sensorTempAvailable = true; - if (sensor1Valid) { - sensorTemp = sensorValue1; - } else if (sensor2Valid) { - sensorTemp = sensorValue2; - } else if (sensor3Valid) { - sensorTemp = sensorValue3; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - //TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sif::error << "ThermalController::chooseSensor: No valid Sensor found"<< std::endl; - sensorTempAvailable = false; - } -} - -void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, - heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, - TempLimits* tempLimit) { +void ThermalController::ctrlComponentTemperature( + heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, + const lp_float_t& sensor5, TempLimits* tempLimit, bool moreThan3Sensors) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensor1, sensor2, sensor3); + chooseSensor(switchNr, sensor1, sensor2, sensor3, sensor4, sensor5, moreThan3Sensors); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 7a7ef7e7..439bc5fe 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -155,14 +155,17 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, - TempLimits* tempLimit); + void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, + const lp_float_t& sensor1, const lp_float_t& sensor2, + const lp_float_t& sensor3, const lp_float_t& sensor4, + const lp_float_t& sensor5, TempLimits* tempLimit, + bool moreThan3Sensors = false); void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); - void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3); - void chooseSensorOldVersion(heater::Switchers switchNr, float sensorValue1, float sensorValue2, - float sensorValue3, bool sensor1Valid, bool sensor2Valid, bool sensor3Valid); + void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, + const lp_float_t& sensor5, bool moreThan3Sensors); void ctrlAcsBoard(); void ctrlMgt(); From 94c178941dddd49822f6cae3107f3ea54efb7bc3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 5 Jan 2023 19:39:51 +0100 Subject: [PATCH 41/59] ThermalController: added sensors to components --- mission/controller/ThermalController.cpp | 116 +++++++++++++---------- mission/controller/ThermalController.h | 11 +-- 2 files changed, 72 insertions(+), 55 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index c1e3cf71..1feef038 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -105,9 +105,9 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - //ctrlCameraBody(); - /*ctrlAcsBoard(); - ctrlMgt(); + // ctrlCameraBody(); + // ctrlAcsBoard(); + /*ctrlMgt(); ctrlRw(); ctrlStr(); ctrlIfBoard(); @@ -976,31 +976,19 @@ void ThermalController::copyDevices() { } } -/* void ThermalController::ctrlAcsBoard() { ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, + deviceTemperatures.gyro1SideA, // mgm1(int), + // sensorTemperatures.sensor_tcs_board, &acsBoardLimits); // TODO: add red sensors } void ThermalController::ctrlMgt() { - heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; - heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; - - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseSensorOldVersion( - switchNr, sensorTemperatures.sensor_magnettorquer.value, deviceTemperatures.mgt.value, - sensorTemperatures.sensor_plpcdu_heatspreader.value, - sensorTemperatures.sensor_magnettorquer.isValid(), deviceTemperatures.mgt.isValid(), - sensorTemperatures.sensor_plpcdu_heatspreader.isValid()); - - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &mgtLimits); - } - } + // TODO: cast deviceTemperatures.mgt + // ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, + // sensorTemperatures.sensor_magnettorquer, deviceTemperatures.mgt, + // sensorTemperatures.sensor_plpcdu_heatspreader, &mgtLimits); } void ThermalController::ctrlRw() { @@ -1021,41 +1009,61 @@ void ThermalController::ctrlIfBoard() { } void ThermalController::ctrlTcsBoard() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &tcsBoardLimits); + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, + sensorTemperatures.sensor_tcs_board, sensorTemperatures.tmp1075Tcs0, + sensorTemperatures.tmp1075Tcs1, &tcsBoardLimits); } void ThermalController::ctrlObc() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcLimits); + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, + deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs1, + sensorTemperatures.tmp1075Tcs0, &obcLimits); } void ThermalController::ctrlObcIfBoard() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, &obcIfBoardLimits); + ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, + deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs0, + sensorTemperatures.tmp1075Tcs1, &obcIfBoardLimits); } void ThermalController::ctrlSBandTransceiver() { ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, - &sBandTransceiverLimits); + deviceTemperatures.syrlinksPowerAmplifier, + deviceTemperatures.syrlinksBasebandBoard, + sensorTemperatures.sensor_4k_camera, &sBandTransceiverLimits); } void ThermalController::ctrlPcduP60Board() { + // TODO: remove sensor3 ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, - &pcduP60BoardLimits); + deviceTemperatures.temp1P60dock, deviceTemperatures.temp2P60dock, + deviceTemperatures.temp2P60dock, &pcduP60BoardLimits); } void ThermalController::ctrlPcduAcu() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduAcuLimits); + // TODO: check sensors (float,3) + // ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, + // deviceTemperatures.acu, deviceTemperatures.acu, sensorTemperatures.sensor_acu, &pcduAcuLimits); } void ThermalController::ctrlPcduPdu() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &pcduPduLimits); + // TODO: remove sensor3 + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, + deviceTemperatures.pdu1, deviceTemperatures.pdu2, + deviceTemperatures.pdu2, &pcduPduLimits); } void ThermalController::ctrlPlPcduBoard() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, &plPcduBoardLimits); + // TODO: add sensor 4: sensorTemperatures.sensor_plpcdu_heatspreader + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, + sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, + deviceTemperatures.adcPayloadPcdu, &plPcduBoardLimits); } void ThermalController::ctrlPlocMissionBoard() { ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, - &plocMissionBoardLimits); + sensorTemperatures.sensor_ploc_heatspreader, + sensorTemperatures.sensor_ploc_missionboard, + sensorTemperatures.sensor_dac_heatspreader, &plocMissionBoardLimits); } void ThermalController::ctrlPlocProcessingBoard() { @@ -1079,29 +1087,41 @@ void ThermalController::ctrlCameraBody() { } void ThermalController::ctrlDro() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &droLimits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, + sensorTemperatures.sensor_dro, sensorTemperatures.sensor_4k_camera, + sensorTemperatures.sensor_mpa, &droLimits); } void ThermalController::ctrlX8() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &x8Limits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, + sensorTemperatures.sensor_x8, sensorTemperatures.sensor_hpa, + sensorTemperatures.sensor_tx_modul, &x8Limits); } void ThermalController::ctrlTx() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &txLimits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, + sensorTemperatures.sensor_tx_modul, sensorTemperatures.sensor_x8, + sensorTemperatures.sensor_mpa, &txLimits); } void ThermalController::ctrlMpa() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &mpaLimits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, + sensorTemperatures.sensor_mpa, sensorTemperatures.sensor_hpa, + sensorTemperatures.sensor_tx_modul, &mpaLimits); } void ThermalController::ctrlHpa() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, &hpaLimits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, + sensorTemperatures.sensor_hpa, sensorTemperatures.sensor_x8, + sensorTemperatures.sensor_mpa, &hpaLimits); } void ThermalController::ctrlScexBoard() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, &scexBoardLimits); + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, + sensorTemperatures.sensor_scex, sensorTemperatures.sensor_x8, + sensorTemperatures.sensor_hpa, &scexBoardLimits); } -*/ + void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit) { // Heater off @@ -1144,7 +1164,6 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, - const lp_float_t& sensor4, const lp_float_t& sensor5, bool moreThan3Sensors) { sensorTempAvailable = true; @@ -1154,10 +1173,10 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ sensorTemp = sensor2.value; } else if (sensor3.isValid()) { sensorTemp = sensor3.value; - } else if (moreThan3Sensors and sensor4.isValid()) { - sensorTemp = sensor4.value; - } else if (moreThan3Sensors and sensor5.isValid()) { - sensorTemp = sensor5.value; + /*} else if (moreThan3Sensors and sensor4.isValid()) { + sensorTemp = sensor4.value; + } else if (moreThan3Sensors and sensor5.isValid()) { + sensorTemp = sensor5.value; */ } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); @@ -1168,15 +1187,16 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ } } - -void ThermalController::ctrlComponentTemperature( - heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, - const lp_float_t& sensor5, TempLimits* tempLimit, bool moreThan3Sensors) { +void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, + heater::Switchers redSwitchNr, + const lp_float_t& sensor1, + const lp_float_t& sensor2, + const lp_float_t& sensor3, TempLimits* tempLimit, + bool moreThan3Sensors) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensor1, sensor2, sensor3, sensor4, sensor5, moreThan3Sensors); + chooseSensor(switchNr, sensor1, sensor2, sensor3, moreThan3Sensors); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 439bc5fe..d43519cf 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -135,7 +135,7 @@ class ThermalController : public ExtendedControllerBase { 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); - float sensorTemp; + static float sensorTemp; bool sensorTempAvailable = true; bool heaterAvailable = true; bool redSwitchNrInUse = false; @@ -157,15 +157,12 @@ class ThermalController : public ExtendedControllerBase { void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, - const lp_float_t& sensor3, const lp_float_t& sensor4, - const lp_float_t& sensor5, TempLimits* tempLimit, + const lp_float_t& sensor3, TempLimits* tempLimit, bool moreThan3Sensors = false); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - struct TempLimits* tempLimit); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, - const lp_float_t& sensor5, bool moreThan3Sensors); + const lp_float_t& sensor2, const lp_float_t& sensor3, bool moreThan3Sensors); void ctrlAcsBoard(); void ctrlMgt(); From 42b570a274da402154681e218b8491da49089ca4 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 16 Jan 2023 17:53:02 +0100 Subject: [PATCH 42/59] comments --- fsfw | 2 +- mission/controller/ThermalController.cpp | 2 +- mission/controller/ThermalController.h | 2 +- tmtc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fsfw b/fsfw index accaf855..05cad893 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit accaf855ee53d3dc429d7bcdf1b7b89768c166b6 +Subproject commit 05cad893a2b713827cf4cdc9afe49675f18afcc7 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 5857bc17..e0e9b3bd 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1130,7 +1130,7 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers struct TempLimits* tempLimit) { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { - // TODO: check if OP or NOP + // TODO: check if OP if (sensorTemp < (*tempLimit).opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 668095de..afffea90 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -160,7 +160,7 @@ class ThermalController : public ExtendedControllerBase { void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit, - bool moreThan3Sensors = false); + bool moreThan3Sensors = false); //TODO sensor 4, 5 = default argument, if not available void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, diff --git a/tmtc b/tmtc index d652c466..56d0f26c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d652c4663b6e738345799026a16d6d2f00d7e65d +Subproject commit 56d0f26cbffbfbf4e790d3a19858162291104934 From 5e7a088da9f157b6da350a090ac3e28dd177629a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 Jan 2023 15:45:54 +0100 Subject: [PATCH 43/59] try to understand the thermal stuff --- bsp_q7s/core/ObjectFactory.cpp | 1 + bsp_q7s/obsw.cpp | 12 ++++++------ mission/controller/ThermalController.cpp | 7 ++++++- mission/controller/ThermalController.h | 10 ++++++---- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 31c027d1..d182caa2 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -914,6 +914,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher) { I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_PL_EIVE); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie, pcdu::Switches::PDU1_CH3_MGT_5V); + imtqHandler->setThermalStateRequestPoolIds(); imtqHandler->setPowerSwitcher(pwrSwitcher); imtqHandler->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); static_cast(imtqHandler); diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index dd0c486b..91bad041 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -1,13 +1,13 @@ #include "obsw.h" +#include +#include +#include + #include #include #include -#include -#include -#include - #include "OBSWConfig.h" #include "commonConfig.h" #include "core/scheduling.h" @@ -44,8 +44,8 @@ int obsw::obsw() { const char* homedir = nullptr; homedir = getenv("HOME"); - if(homedir == nullptr) { - homedir = getpwuid(getuid())->pw_dir; + if (homedir == nullptr) { + homedir = getpwuid(getuid())->pw_dir; } std::filesystem::path bootDelayFile = std::filesystem::path(homedir) / "boot_delay_secs.txt"; // Init delay handling. diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index e0e9b3bd..a14f4f13 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include #include @@ -20,6 +22,7 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), + imtqThermalSet(objects::IMTQ_HANDLER), max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD, @@ -990,6 +993,8 @@ void ThermalController::ctrlAcsBoard() { void ThermalController::ctrlMgt() { // TODO: cast deviceTemperatures.mgt + PoolReadGuard pg(&imtqThermalSet); + ThermalComponentIF::StateRequest heaterReq = imtqThermalSet.heaterRequest.value; // ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, // sensorTemperatures.sensor_magnettorquer, deviceTemperatures.mgt, // sensorTemperatures.sensor_plpcdu_heatspreader, &mgtLimits); @@ -1206,4 +1211,4 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, ctrlHeater(switchNr, redSwitchNr, tempLimit); } } -} \ No newline at end of file +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index afffea90..96f0c60a 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -73,6 +73,8 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; + DeviceHandlerThermalSet imtqThermalSet; + // Temperature Sensors MAX31865::PrimarySet max31865Set0; MAX31865::PrimarySet max31865Set1; @@ -157,10 +159,10 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, - const lp_float_t& sensor1, const lp_float_t& sensor2, - const lp_float_t& sensor3, TempLimits* tempLimit, - bool moreThan3Sensors = false); //TODO sensor 4, 5 = default argument, if not available + void ctrlComponentTemperature( + heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit, + bool moreThan3Sensors = false); // TODO sensor 4, 5 = default argument, if not available void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, From d447f4ba42d1fa3f17c2cbb2c0ac8ea56e3afdfb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 Jan 2023 15:55:36 +0100 Subject: [PATCH 44/59] now it compiles --- common/config/eive/eventSubsystemIds.h | 1 + mission/controller/ThermalController.cpp | 5 +++-- mission/controller/ThermalController.h | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/config/eive/eventSubsystemIds.h b/common/config/eive/eventSubsystemIds.h index 8785f599..29afe97e 100644 --- a/common/config/eive/eventSubsystemIds.h +++ b/common/config/eive/eventSubsystemIds.h @@ -35,6 +35,7 @@ enum : uint8_t { SYRLINKS = 137, SCEX_HANDLER = 138, CONFIGHANDLER = 139, + TCS_CONTROLLER = 140, COMMON_SUBSYSTEM_ID_END }; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index a14f4f13..0861c08a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -994,7 +994,8 @@ void ThermalController::ctrlAcsBoard() { void ThermalController::ctrlMgt() { // TODO: cast deviceTemperatures.mgt PoolReadGuard pg(&imtqThermalSet); - ThermalComponentIF::StateRequest heaterReq = imtqThermalSet.heaterRequest.value; + ThermalComponentIF::StateRequest heaterReq = + static_cast(imtqThermalSet.heaterRequest.value); // ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, // sensorTemperatures.sensor_magnettorquer, deviceTemperatures.mgt, // sensorTemperatures.sensor_plpcdu_heatspreader, &mgtLimits); @@ -1162,7 +1163,7 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch redSwitchNrInUse = true; } else { heaterAvailable = false; - // TODO: triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); sif::error << "ThermalController::chooseSensor: Both heater: " << switchNr << " + " << redSwitchNr << " not healthy" << std::endl; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 96f0c60a..c97b3fdc 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,6 +2,7 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include +#include #include #include #include @@ -54,9 +55,9 @@ class ThermalController : public ExtendedControllerBase { uint32_t* msToReachTheMode) override; private: - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static constexpr Event NO_VALID_SENSOR_TEMPERATURE = MAKE_EVENT(8, severity::MEDIUM); - static constexpr Event NO_HEALTHY_HEATER_AVAILABLE = MAKE_EVENT(9, severity::MEDIUM); + 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 const uint32_t DELAY = 500; @@ -139,7 +140,7 @@ class ThermalController : public ExtendedControllerBase { 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); - static float sensorTemp; + float sensorTemp = 0.0; bool sensorTempAvailable = true; bool heaterAvailable = true; bool redSwitchNrInUse = false; From 58f1c93de5fd8167f27a346c932f1c6952c653c8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 Jan 2023 16:16:59 +0100 Subject: [PATCH 45/59] add some stuff --- dummies/DummyHeaterHandler.cpp | 4 ---- dummies/DummyHeaterHandler.h | 13 ------------- dummies/Max31865Dummy.cpp | 5 +++++ dummies/Max31865Dummy.h | 1 + dummies/TemperatureSensorInserter.cpp | 14 ++++++++------ dummies/TemperatureSensorInserter.h | 11 +++++++---- dummies/helpers.cpp | 5 ++++- 7 files changed, 25 insertions(+), 28 deletions(-) delete mode 100644 dummies/DummyHeaterHandler.cpp delete mode 100644 dummies/DummyHeaterHandler.h diff --git a/dummies/DummyHeaterHandler.cpp b/dummies/DummyHeaterHandler.cpp deleted file mode 100644 index 59c49bde..00000000 --- a/dummies/DummyHeaterHandler.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// -// Created by irini on 24.11.22. -// -#include "DummyHeaterHandler.h" diff --git a/dummies/DummyHeaterHandler.h b/dummies/DummyHeaterHandler.h deleted file mode 100644 index 8fb1e80b..00000000 --- a/dummies/DummyHeaterHandler.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// Created by irini on 24.11.22. -// - -#ifndef EIVE_OBSW_DUMMYHEATERHANDLER_H -#define EIVE_OBSW_DUMMYHEATERHANDLER_H - -#include "mission/devices/HeaterHandler.h" -class DummyHeaterHandler : public HeaterHandler { - public: - // DummyHeaterHandler(); -}; -#endif // EIVE_OBSW_DUMMYHEATERHANDLER_H diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index 5cbd1dec..687620ba 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -34,6 +34,11 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD localDataPoolMap.emplace(static_cast(PoolIds::FAULT_BYTE), new PoolEntry({0})); return OK; } + +void Max31865Dummy::setTemperature(float temperature) { + set.temperatureCelcius.value = temperature; +} + LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } Max31865Dummy::Max31865Dummy(object_id_t objectId, CookieIF *cookie) : DeviceHandlerBase(objectId, objects::DUMMY_COM_IF, cookie), diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index 011296d6..58655870 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -9,6 +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); private: MAX31865::PrimarySet set; diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 314f7496..028f95ee 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -6,14 +6,14 @@ #include TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId) - : SystemObject(objects::THERMAL_TEMP_INSERTER), - max31865PlocHeatspreaderSet(objects::RTD_0_IC3_PLOC_HEATSPREADER, MAX31865::MAX31865_SET_ID), - max31865PlocMissionboardSet(objects::RTD_1_IC4_PLOC_MISSIONBOARD, MAX31865::MAX31865_SET_ID) { -} + : SystemObject(objects::THERMAL_TEMP_INSERTER) {} ReturnValue_t TemperatureSensorInserter::initialize() { - max31865PlocHeatspreaderSet.temperatureCelcius = 20.0; - max31865PlocMissionboardSet.temperatureCelcius = 20.0; + if (performTest) { + if(testCase == TestCase::OVERCOOL_SYRLINKS) { + + } + } return returnvalue::OK; } @@ -21,6 +21,7 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { iteration++; value = sin(iteration / 80. * M_PI) * 10; + /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { sif::warning << "Failed to read temperature from MAX31865 dataset" << std::endl; @@ -33,5 +34,6 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { max31865PlocHeatspreaderSet.setValidity(true, true); } max31865PlocHeatspreaderSet.commit(); + */ return returnvalue::OK; } diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 8c87176d..38604b6d 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -13,10 +13,13 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject ReturnValue_t performOperation(uint8_t opCode) override; private: - int iteration = 0; - float value = 0; - MAX31865::PrimarySet max31865PlocHeatspreaderSet; - MAX31865::PrimarySet max31865PlocMissionboardSet; + enum TestCase { + OVERCOOL_SYRLINKS = 0 + }; + int iteration = 0; + bool performTest = false; + float value = 0; + TestCase testCase; // void noise(); }; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index a9e34e2f..470f6b29 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -82,7 +82,9 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { - new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); + + std::map tempSensorDummies; + tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy)); new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, objects::DUMMY_COM_IF, comCookieDummy); new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy); new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); @@ -104,6 +106,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy); new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy); new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); } new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); From fdcd8e2800f41a026be456a1e183a1fc5d2d09e0 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sat, 21 Jan 2023 16:51:32 +0100 Subject: [PATCH 46/59] tempSensorDummies map --- dummies/Max31865Dummy.cpp | 2 +- dummies/Max31865Dummy.h | 1 + dummies/TemperatureSensorInserter.cpp | 13 ++-- dummies/TemperatureSensorInserter.h | 16 +++-- dummies/helpers.cpp | 91 ++++++++++++++++++++------- 5 files changed, 88 insertions(+), 35 deletions(-) diff --git a/dummies/Max31865Dummy.cpp b/dummies/Max31865Dummy.cpp index 687620ba..43198bba 100644 --- a/dummies/Max31865Dummy.cpp +++ b/dummies/Max31865Dummy.cpp @@ -36,7 +36,7 @@ ReturnValue_t Max31865Dummy::initializeLocalDataPool(localpool::DataPool &localD } void Max31865Dummy::setTemperature(float temperature) { - set.temperatureCelcius.value = temperature; + set.temperatureCelcius.value = temperature; } LocalPoolDataSetBase *Max31865Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/dummies/Max31865Dummy.h b/dummies/Max31865Dummy.h index 58655870..79f4ddb4 100644 --- a/dummies/Max31865Dummy.h +++ b/dummies/Max31865Dummy.h @@ -10,6 +10,7 @@ class Max31865Dummy : public DeviceHandlerBase { Max31865Dummy(object_id_t objectId, CookieIF *comCookie); void setTemperature(float temperature); + private: MAX31865::PrimarySet set; diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 028f95ee..791a1d51 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -5,14 +5,17 @@ #include #include -TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId) - : SystemObject(objects::THERMAL_TEMP_INSERTER) {} +TemperatureSensorInserter::TemperatureSensorInserter( + object_id_t objectId, std::map tempSensorDummies_, + std::map tempTmpSensorDummies_) + : SystemObject(objects::THERMAL_TEMP_INSERTER), + tempSensorDummies(tempSensorDummies_), + tempTmpSensorDummies(tempTmpSensorDummies_) {} ReturnValue_t TemperatureSensorInserter::initialize() { if (performTest) { - if(testCase == TestCase::OVERCOOL_SYRLINKS) { - - } + if (testCase == TestCase::OVERCOOL_SYRLINKS) { + } } return returnvalue::OK; } diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 38604b6d..18bac79c 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -3,9 +3,14 @@ #include #include +#include "Max31865Dummy.h" +#include "Tmp1075Dummy.h" + class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: - explicit TemperatureSensorInserter(object_id_t objectId); + explicit TemperatureSensorInserter(object_id_t objectId, + std::map tempSensorDummies_, + std::map tempTmpSensorDummies_); ReturnValue_t initialize() override; @@ -13,13 +18,14 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject ReturnValue_t performOperation(uint8_t opCode) override; private: - - enum TestCase { - OVERCOOL_SYRLINKS = 0 - }; + enum TestCase { OVERCOOL_SYRLINKS = 0 }; int iteration = 0; bool performTest = false; float value = 0; TestCase testCase; + + std::map tempSensorDummies; + std::map tempTmpSensorDummies; + // void noise(); }; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 470f6b29..db57d5ff 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -82,32 +82,75 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { - std::map tempSensorDummies; - tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy)); - new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_4_IC7_STARTRACKER, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_5_IC8_RW1_MX_MY, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_6_IC9_DRO, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_7_IC10_SCEX, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_8_IC11_X8, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_9_IC12_HPA, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, objects::DUMMY_COM_IF, - comCookieDummy); - new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy); - new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy); - new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy); - new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy); - new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy); - new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy); - new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy); + tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, + new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_2_IC5_4K_CAMERA, + new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace(objects::RTD_3_IC6_DAC_HEATSPREADER, + new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_4_IC7_STARTRACKER, + new Max31865Dummy(objects::RTD_4_IC7_STARTRACKER, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_5_IC8_RW1_MX_MY, + new Max31865Dummy(objects::RTD_5_IC8_RW1_MX_MY, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_6_IC9_DRO, + new Max31865Dummy(objects::RTD_6_IC9_DRO, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_7_IC10_SCEX, + new Max31865Dummy(objects::RTD_7_IC10_SCEX, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_8_IC11_X8, + new Max31865Dummy(objects::RTD_8_IC11_X8, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_9_IC12_HPA, + new Max31865Dummy(objects::RTD_9_IC12_HPA, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_10_IC13_PL_TX, + new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_11_IC14_MPA, + new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_12_IC15_ACU, + new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_14_IC17_TCS_BOARD, + new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); + tempSensorDummies.emplace( + objects::RTD_15_IC18_IMTQ, + new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); + std::map tempTmpSensorDummies; + tempTmpSensorDummies.emplace( + objects::TMP1075_HANDLER_TCS_0, + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); + tempTmpSensorDummies.emplace( + objects::TMP1075_HANDLER_TCS_1, + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy)); + tempTmpSensorDummies.emplace( + objects::TMP1075_HANDLER_PLPCDU_0, + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy)); + tempTmpSensorDummies.emplace( + objects::TMP1075_HANDLER_PLPCDU_1, + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy)); + tempTmpSensorDummies.emplace( + 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); } new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); From 2b3fe93906e3f31f352ef74a531a915311f78e49 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 22 Jan 2023 20:07:10 +0100 Subject: [PATCH 47/59] constructor TemperatureSensorInserter + temSensorDummies-map --- dummies/CMakeLists.txt | 3 +-- dummies/TemperatureSensorInserter.cpp | 8 +++----- dummies/TemperatureSensorInserter.h | 9 +++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 51d4d4a2..330aecfe 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -22,5 +22,4 @@ target_sources( CoreControllerDummy.cpp helpers.cpp MgmRm3100Dummy.cpp - Tmp1075Dummy.cpp - DummyHeaterHandler.cpp) + Tmp1075Dummy.cpp) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 791a1d51..4852440f 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -6,11 +6,9 @@ #include TemperatureSensorInserter::TemperatureSensorInserter( - object_id_t objectId, std::map tempSensorDummies_, - std::map tempTmpSensorDummies_) - : SystemObject(objects::THERMAL_TEMP_INSERTER), - tempSensorDummies(tempSensorDummies_), - tempTmpSensorDummies(tempTmpSensorDummies_) {} + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_) + : SystemObject(objects::THERMAL_TEMP_INSERTER) {} ReturnValue_t TemperatureSensorInserter::initialize() { if (performTest) { diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 18bac79c..1cf49e01 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -8,9 +8,9 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: - explicit TemperatureSensorInserter(object_id_t objectId, - std::map tempSensorDummies_, - std::map tempTmpSensorDummies_); + explicit TemperatureSensorInserter( + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_); ReturnValue_t initialize() override; @@ -24,8 +24,5 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject float value = 0; TestCase testCase; - std::map tempSensorDummies; - std::map tempTmpSensorDummies; - // void noise(); }; From 6fd10e718093f4b17f9ca3c4dff61dc628e89d2e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 22 Jan 2023 20:37:51 +0100 Subject: [PATCH 48/59] bug fixed --- dummies/TemperatureSensorInserter.cpp | 4 +- dummies/TemperatureSensorInserter.h | 4 +- dummies/helpers.cpp | 4 +- mission/controller/ThermalController.cpp | 59 ++++++++++++++++-------- mission/controller/ThermalController.h | 7 +-- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 4852440f..58748e87 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -6,8 +6,8 @@ #include TemperatureSensorInserter::TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_) + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_) : SystemObject(objects::THERMAL_TEMP_INSERTER) {} ReturnValue_t TemperatureSensorInserter::initialize() { diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 1cf49e01..cf858576 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -9,8 +9,8 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: explicit TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_); + object_id_t objectId, const std::map& tempSensorDummies_, + const std::map& tempTmpSensorDummies_); ReturnValue_t initialize() override; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index db57d5ff..91e61aa4 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -82,7 +82,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addTempSensorDummies) { - std::map tempSensorDummies; + std::map tempSensorDummies; tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, objects::DUMMY_COM_IF, comCookieDummy)); @@ -132,7 +132,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { objects::RTD_15_IC18_IMTQ, new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - std::map tempTmpSensorDummies; + std::map tempTmpSensorDummies; tempTmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 0861c08a..d11eda72 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -984,11 +984,20 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { - ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_0_OBC_BRD, - deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, // mgm1(int), - // sensorTemperatures.sensor_tcs_board, - &acsBoardLimits); // TODO: add red sensors +// TODO: add red sensors, check sensor 4 + heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; + heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + /*chooseOf5Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, deviceTemperatures.mgt, + sensorTemperatures.sensor_tcs_board);*/ + + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + } + } } void ThermalController::ctrlMgt() { @@ -1164,8 +1173,6 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } else { heaterAvailable = false; triggerEvent(NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); - sif::error << "ThermalController::chooseSensor: Both heater: " << switchNr << " + " - << redSwitchNr << " not healthy" << std::endl; } } else { redSwitchNrInUse = false; @@ -1173,8 +1180,7 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, - bool moreThan3Sensors) { + const lp_float_t& sensor2, const lp_float_t& sensor3) { sensorTempAvailable = true; if (sensor1.isValid()) { @@ -1183,16 +1189,11 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ sensorTemp = sensor2.value; } else if (sensor3.isValid()) { sensorTemp = sensor3.value; - /*} else if (moreThan3Sensors and sensor4.isValid()) { - sensorTemp = sensor4.value; - } else if (moreThan3Sensors and sensor5.isValid()) { - sensorTemp = sensor5.value; */ } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); } - // TODO: triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sif::error << "ThermalController::chooseSensor: No valid Sensor found" << std::endl; + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; } } @@ -1201,15 +1202,37 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, - const lp_float_t& sensor3, TempLimits* tempLimit, - bool moreThan3Sensors) { + const lp_float_t& sensor3, TempLimits* tempLimit) { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - chooseSensor(switchNr, sensor1, sensor2, sensor3, moreThan3Sensors); + chooseSensor(switchNr, sensor1, sensor2, sensor3); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, tempLimit); } } } +void ThermalController::chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, + const lp_float_t& sensor4, const lp_float_t& sensor5) { + sensorTempAvailable = true; + + if (sensor1.isValid()) { + sensorTemp = sensor1.value; + } else if (sensor2.isValid()) { + sensorTemp = sensor2.value; + } else if (sensor3.isValid()) { + sensorTemp = sensor3.value; + } else if (sensor4.isValid()) { + sensorTemp = sensor4.value; + } else if (sensor5.isValid()) { + sensorTemp = sensor5.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } +} diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index c97b3fdc..7f3e8ac7 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -162,12 +162,13 @@ class ThermalController : public ExtendedControllerBase { void ctrlComponentTemperature( heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit, - bool moreThan3Sensors = false); // TODO sensor 4, 5 = default argument, if not available + const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit); // TODO sensor 4, 5 = default argument, if not available void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, bool moreThan3Sensors); + const lp_float_t& sensor2, const lp_float_t& sensor3); + void chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, const lp_float_t& sensor5); void ctrlAcsBoard(); void ctrlMgt(); From 0e2ae50fc5e58208f1877c106462b6244401068f Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 22 Jan 2023 21:04:55 +0100 Subject: [PATCH 49/59] ThermalController changes --- mission/controller/ThermalController.cpp | 59 +++++++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index d11eda72..b05b3a07 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1059,9 +1059,31 @@ void ThermalController::ctrlPcduP60Board() { } void ThermalController::ctrlPcduAcu() { - // TODO: check sensors (float,3) - // ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, - // deviceTemperatures.acu, deviceTemperatures.acu, sensorTemperatures.sensor_acu, &pcduAcuLimits); + heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; + heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + sensorTempAvailable = true; + + if (deviceTemperatures.acu.isValid()) { // TODO: how to check the different values + sensorTemp = deviceTemperatures.acu.value[0]; // TODO: check if right + } else if (deviceTemperatures.acu.isValid()) { + sensorTemp = deviceTemperatures.acu.value[1]; + } else if (sensorTemperatures.sensor_acu.isValid()) { + sensorTemp = sensorTemperatures.sensor_acu.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &pcduAcuLimits); + } + } + } } void ThermalController::ctrlPcduPdu() { @@ -1072,10 +1094,33 @@ void ThermalController::ctrlPcduPdu() { } void ThermalController::ctrlPlPcduBoard() { - // TODO: add sensor 4: sensorTemperatures.sensor_plpcdu_heatspreader - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, - sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, - deviceTemperatures.adcPayloadPcdu, &plPcduBoardLimits); + heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; + heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + sensorTempAvailable = true; + + if (sensorTemperatures.tmp1075PlPcdu0.isValid()) { + sensorTemp = sensorTemperatures.tmp1075PlPcdu0.value; + } else if (sensorTemperatures.tmp1075PlPcdu1.isValid()) { + sensorTemp = sensorTemperatures.tmp1075PlPcdu1.value; + } else if (deviceTemperatures.adcPayloadPcdu.isValid()) { + sensorTemp = deviceTemperatures.adcPayloadPcdu.value; + } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { + sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); + } + } + } } void ThermalController::ctrlPlocMissionBoard() { From 95fe06a09b7d279254a458eda6a6389086771d0c Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 23 Jan 2023 22:29:29 +0100 Subject: [PATCH 50/59] ThermalController additions --- mission/controller/ThermalController.cpp | 206 ++++++++++++++++++----- mission/controller/ThermalController.h | 12 +- 2 files changed, 174 insertions(+), 44 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b05b3a07..7d4ee75b 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -109,9 +109,9 @@ void ThermalController::performControlOperation() { } // TODO: Heater control - // ctrlCameraBody(); - // ctrlAcsBoard(); - /*ctrlMgt(); + ctrlCameraBody(); + ctrlAcsBoard(); + ctrlMgt(); ctrlRw(); ctrlStr(); ctrlIfBoard(); @@ -132,7 +132,7 @@ void ThermalController::performControlOperation() { ctrlHpa(); ctrlTx(); ctrlMpa(); - ctrlScexBoard();*/ + ctrlScexBoard(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -984,16 +984,23 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { -// TODO: add red sensors, check sensor 4 + // TODO: check sensor 4; A:MGM1(int); B: MGM3(int) heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - /*chooseOf5Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, deviceTemperatures.mgt, - sensorTemperatures.sensor_tcs_board);*/ - + // A side + chooseOf5Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, deviceTemperatures.mgm0SideA, + sensorTemperatures.sensor_tcs_board); + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + } + // B side + chooseOf5Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, + deviceTemperatures.gyro3SideB, deviceTemperatures.mgm2SideB, + sensorTemperatures.sensor_tcs_board); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); } @@ -1001,18 +1008,129 @@ void ThermalController::ctrlAcsBoard() { } void ThermalController::ctrlMgt() { - // TODO: cast deviceTemperatures.mgt + // TODO: use heaterReq PoolReadGuard pg(&imtqThermalSet); ThermalComponentIF::StateRequest heaterReq = static_cast(imtqThermalSet.heaterRequest.value); - // ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, - // sensorTemperatures.sensor_magnettorquer, deviceTemperatures.mgt, - // sensorTemperatures.sensor_plpcdu_heatspreader, &mgtLimits); + + if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { + heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; + heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; + + chooseHeater(switchNr, redSwitchNr); + + if (heaterAvailable) { + sensorTempAvailable = true; + + if (sensorTemperatures.sensor_magnettorquer.isValid()) { + sensorTemp = sensorTemperatures.sensor_magnettorquer.value; + } else if (deviceTemperatures.mgt.isValid()) { + sensorTemp = deviceTemperatures.mgt.value; + } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { + sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &mgtLimits); + } + } + } } void ThermalController::ctrlRw() { - // ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, - // sensorTemperatures.sensor_rw1, deviceTemperatures.rw1, deviceTemperatures.rw3, &rwLimits); + heater::Switchers switchNr = heater::HEATER_6_DRO; + heater::Switchers redSwitchNr = heater::HEATER_6_DRO; + redSwitchNrInUse = false; + + if (heaterHandler.getHealth(switchNr) == HasHealthIF::HEALTHY) { + // RW1 + sensorTempAvailable = true; + + if (sensorTemperatures.sensor_rw1.isValid()) { + sensorTemp = sensorTemperatures.sensor_rw1.value; + } else if (deviceTemperatures.rw1.isValid()) { + sensorTemp = deviceTemperatures.rw1.value; + } else if (deviceTemperatures.rw4.isValid()) { + sensorTemp = deviceTemperatures.rw4.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + sensorTemp = sensorTemperatures.sensor_dro.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &rwLimits); + } + // RW2 + sensorTempAvailable = true; + if (deviceTemperatures.rw2.isValid()) { + sensorTemp = deviceTemperatures.rw2.value; + } else if (deviceTemperatures.rw3.isValid()) { + sensorTemp = deviceTemperatures.rw3.value; + } else if (sensorTemperatures.sensor_rw1.isValid()) { + sensorTemp = sensorTemperatures.sensor_rw1.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + sensorTemp = sensorTemperatures.sensor_dro.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &rwLimits); + } + // RW3 + sensorTempAvailable = true; + if (deviceTemperatures.rw3.isValid()) { + sensorTemp = deviceTemperatures.rw3.value; + } else if (deviceTemperatures.rw4.isValid()) { + sensorTemp = deviceTemperatures.rw4.value; + } else if (sensorTemperatures.sensor_rw1.isValid()) { + sensorTemp = sensorTemperatures.sensor_rw1.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + sensorTemp = sensorTemperatures.sensor_dro.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &rwLimits); + } + // RW4 + sensorTempAvailable = true; + if (deviceTemperatures.rw4.isValid()) { + sensorTemp = deviceTemperatures.rw4.value; + } else if (deviceTemperatures.rw1.isValid()) { + sensorTemp = deviceTemperatures.rw1.value; + } else if (sensorTemperatures.sensor_rw1.isValid()) { + sensorTemp = sensorTemperatures.sensor_rw1.value; + } else if (sensorTemperatures.sensor_dro.isValid()) { + sensorTemp = sensorTemperatures.sensor_dro.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &rwLimits); + } + } } void ThermalController::ctrlStr() { @@ -1079,9 +1197,10 @@ void ThermalController::ctrlPcduAcu() { } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &pcduAcuLimits); - } + + } + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &pcduAcuLimits); } } } @@ -1100,26 +1219,12 @@ void ThermalController::ctrlPlPcduBoard() { chooseHeater(switchNr, redSwitchNr); if (heaterAvailable) { - sensorTempAvailable = true; - - if (sensorTemperatures.tmp1075PlPcdu0.isValid()) { - sensorTemp = sensorTemperatures.tmp1075PlPcdu0.value; - } else if (sensorTemperatures.tmp1075PlPcdu1.isValid()) { - sensorTemp = sensorTemperatures.tmp1075PlPcdu1.value; - } else if (deviceTemperatures.adcPayloadPcdu.isValid()) { - sensorTemp = deviceTemperatures.adcPayloadPcdu.value; - } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { - sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); - } - } + chooseOf4Sensors(switchNr, sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, + deviceTemperatures.adcPayloadPcdu, + sensorTemperatures.sensor_plpcdu_heatspreader); + if (sensorTempAvailable) { + ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); + } } } @@ -1258,6 +1363,27 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, } } } +void ThermalController::chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, + const lp_float_t& sensor4) { + sensorTempAvailable = true; + + if (sensor1.isValid()) { + sensorTemp = sensor1.value; + } else if (sensor2.isValid()) { + sensorTemp = sensor2.value; + } else if (sensor3.isValid()) { + sensorTemp = sensor3.value; + } else if (sensor4.isValid()) { + sensorTemp = sensor4.value; + } else { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + } + triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); + sensorTempAvailable = false; + } +} void ThermalController::chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, const lp_float_t& sensor5) { @@ -1270,9 +1396,9 @@ void ThermalController::chooseOf5Sensors(heater::Switchers switchNr, const lp_fl } else if (sensor3.isValid()) { sensorTemp = sensor3.value; } else if (sensor4.isValid()) { - sensorTemp = sensor4.value; + sensorTemp = sensor4.value; } else if (sensor5.isValid()) { - sensorTemp = sensor5.value; + sensorTemp = sensor5.value; } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 7f3e8ac7..5f2fe371 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -160,15 +160,19 @@ class ThermalController : public ExtendedControllerBase { void copySus(); void copyDevices(); - void ctrlComponentTemperature( - heater::Switchers switchNr, heater::Switchers redSwitchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, TempLimits* tempLimit); // TODO sensor 4, 5 = default argument, if not available + void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, + const lp_float_t& sensor1, const lp_float_t& sensor2, + const lp_float_t& sensor3, TempLimits* tempLimit); void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3); + void chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, + const lp_float_t& sensor2, const lp_float_t& sensor3, + const lp_float_t& sensor4); void chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4, const lp_float_t& sensor5); + const lp_float_t& sensor2, const lp_float_t& sensor3, + const lp_float_t& sensor4, const lp_float_t& sensor5); void ctrlAcsBoard(); void ctrlMgt(); From fa7281794a6c7a4a5a24168da713f7d44e651322 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sat, 28 Jan 2023 22:51:51 +0100 Subject: [PATCH 51/59] deleted comments fromm ThermalController --- linux/ObjectFactory.cpp | 5 ++-- linux/ObjectFactory.h | 1 + mission/controller/ThermalController.cpp | 31 +++++++++--------------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 4ce69b2d..18c00745 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -24,6 +24,7 @@ #include "devices/addresses.h" #include "devices/gpioIds.h" #include "eive/definitions.h" +#include "mission/controller/ThermalController.h" #include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "mission/system/tree/tcsModeTree.h" @@ -348,8 +349,8 @@ void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwr scexHandler->connectModeTreeParent(satsystem::pl::SUBSYSTEM); } -void ObjectFactory::createThermalController() { - auto* tcsCtrl = new ThermalController(objects::THERMAL_CONTROLLER); +void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { + auto* tcsCtrl = new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler); tcsCtrl->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 4558aa78..a12617a6 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -36,4 +36,5 @@ AcsController* createAcsController(bool connectSubsystem); void addTmtcIpCoresToFunnels(CcsdsIpCoreHandler& ipCoreHandler, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel); +void createThermalController(HeaterHandler& heaterHandler); } // namespace ObjectFactory diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 7d4ee75b..2d8a2b22 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -108,7 +108,6 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } - // TODO: Heater control ctrlCameraBody(); ctrlAcsBoard(); ctrlMgt(); @@ -984,7 +983,6 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { - // TODO: check sensor 4; A:MGM1(int); B: MGM3(int) heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; chooseHeater(switchNr, redSwitchNr); @@ -1008,9 +1006,8 @@ void ThermalController::ctrlAcsBoard() { } void ThermalController::ctrlMgt() { - // TODO: use heaterReq PoolReadGuard pg(&imtqThermalSet); - ThermalComponentIF::StateRequest heaterReq = + auto heaterReq = static_cast(imtqThermalSet.heaterRequest.value); if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { @@ -1034,7 +1031,6 @@ void ThermalController::ctrlMgt() { } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; - } if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &mgtLimits); @@ -1055,9 +1051,9 @@ void ThermalController::ctrlRw() { if (sensorTemperatures.sensor_rw1.isValid()) { sensorTemp = sensorTemperatures.sensor_rw1.value; } else if (deviceTemperatures.rw1.isValid()) { - sensorTemp = deviceTemperatures.rw1.value; + sensorTemp = static_cast(deviceTemperatures.rw1.value); } else if (deviceTemperatures.rw4.isValid()) { - sensorTemp = deviceTemperatures.rw4.value; + sensorTemp = static_cast(deviceTemperatures.rw4.value); } else if (sensorTemperatures.sensor_dro.isValid()) { sensorTemp = sensorTemperatures.sensor_dro.value; } else { @@ -1073,9 +1069,9 @@ void ThermalController::ctrlRw() { // RW2 sensorTempAvailable = true; if (deviceTemperatures.rw2.isValid()) { - sensorTemp = deviceTemperatures.rw2.value; + sensorTemp = static_cast(deviceTemperatures.rw2.value); } else if (deviceTemperatures.rw3.isValid()) { - sensorTemp = deviceTemperatures.rw3.value; + sensorTemp = static_cast(deviceTemperatures.rw3.value); } else if (sensorTemperatures.sensor_rw1.isValid()) { sensorTemp = sensorTemperatures.sensor_rw1.value; } else if (sensorTemperatures.sensor_dro.isValid()) { @@ -1093,9 +1089,9 @@ void ThermalController::ctrlRw() { // RW3 sensorTempAvailable = true; if (deviceTemperatures.rw3.isValid()) { - sensorTemp = deviceTemperatures.rw3.value; + sensorTemp = static_cast(deviceTemperatures.rw3.value); } else if (deviceTemperatures.rw4.isValid()) { - sensorTemp = deviceTemperatures.rw4.value; + sensorTemp = static_cast(deviceTemperatures.rw4.value); } else if (sensorTemperatures.sensor_rw1.isValid()) { sensorTemp = sensorTemperatures.sensor_rw1.value; } else if (sensorTemperatures.sensor_dro.isValid()) { @@ -1113,9 +1109,9 @@ void ThermalController::ctrlRw() { // RW4 sensorTempAvailable = true; if (deviceTemperatures.rw4.isValid()) { - sensorTemp = deviceTemperatures.rw4.value; + sensorTemp = static_cast(deviceTemperatures.rw4.value); } else if (deviceTemperatures.rw1.isValid()) { - sensorTemp = deviceTemperatures.rw1.value; + sensorTemp = static_cast(deviceTemperatures.rw1.value); } else if (sensorTemperatures.sensor_rw1.isValid()) { sensorTemp = sensorTemperatures.sensor_rw1.value; } else if (sensorTemperatures.sensor_dro.isValid()) { @@ -1170,7 +1166,6 @@ void ThermalController::ctrlSBandTransceiver() { sensorTemperatures.sensor_4k_camera, &sBandTransceiverLimits); } void ThermalController::ctrlPcduP60Board() { - // TODO: remove sensor3 ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, deviceTemperatures.temp1P60dock, deviceTemperatures.temp2P60dock, deviceTemperatures.temp2P60dock, &pcduP60BoardLimits); @@ -1185,8 +1180,8 @@ void ThermalController::ctrlPcduAcu() { if (heaterAvailable) { sensorTempAvailable = true; - if (deviceTemperatures.acu.isValid()) { // TODO: how to check the different values - sensorTemp = deviceTemperatures.acu.value[0]; // TODO: check if right + if (deviceTemperatures.acu.isValid()) { + sensorTemp = deviceTemperatures.acu.value[0]; } else if (deviceTemperatures.acu.isValid()) { sensorTemp = deviceTemperatures.acu.value[1]; } else if (sensorTemperatures.sensor_acu.isValid()) { @@ -1197,7 +1192,6 @@ void ThermalController::ctrlPcduAcu() { } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; - } if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &pcduAcuLimits); @@ -1206,7 +1200,6 @@ void ThermalController::ctrlPcduAcu() { } void ThermalController::ctrlPcduPdu() { - // TODO: remove sensor3 ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, deviceTemperatures.pdu1, deviceTemperatures.pdu2, deviceTemperatures.pdu2, &pcduPduLimits); @@ -1295,7 +1288,6 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers struct TempLimits* tempLimit) { // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { - // TODO: check if OP if (sensorTemp < (*tempLimit).opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); } @@ -1363,6 +1355,7 @@ void ThermalController::ctrlComponentTemperature(heater::Switchers switchNr, } } } + void ThermalController::chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4) { From 617507b3d445309242567010d4f6e34052551a8e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 29 Jan 2023 17:55:43 +0100 Subject: [PATCH 52/59] small changes ThermalController --- mission/controller/ThermalController.cpp | 6 ++++-- mission/controller/ThermalController.h | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 2d8a2b22..0f285530 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1180,10 +1180,12 @@ void ThermalController::ctrlPcduAcu() { if (heaterAvailable) { sensorTempAvailable = true; - if (deviceTemperatures.acu.isValid()) { + if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; - } else if (deviceTemperatures.acu.isValid()) { + } else if (deviceTemperatures.acu.value[1] != INVALID_TEMPERATURE) { 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 { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 5f2fe371..1f977524 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -61,7 +61,6 @@ class ThermalController : public ExtendedControllerBase { static const uint32_t DELAY = 500; - // TODO to be changed static const uint32_t TEMP_OFFSET = 5; enum class InternalState { STARTUP, INITIAL_DELAY, READY }; From 519d55af4bc967b851b1e2944394b485b36c73cc Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 3 Feb 2023 13:19:39 +0100 Subject: [PATCH 53/59] ThermalController: events for overheating --- linux/ObjectFactory.cpp | 9 --- mission/controller/ThermalController.cpp | 70 +++++++++++------------- mission/controller/ThermalController.h | 9 ++- mission/devices/HeaterHandler.cpp | 1 - 4 files changed, 39 insertions(+), 50 deletions(-) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 67925a81..e684b7cb 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,25 +9,16 @@ #include #include #include -#include #include -#include #include -#include -#include -#include -#include -#include #include "OBSWConfig.h" #include "devConf.h" #include "devices/addresses.h" #include "devices/gpioIds.h" #include "eive/definitions.h" -#include "mission/controller/ThermalController.h" #include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/payloadModeTree.h" -#include "mission/system/tree/tcsModeTree.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, std::string spiDev, diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 033e66b0..8535228a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -989,16 +988,14 @@ void ThermalController::ctrlAcsBoard() { if (heaterAvailable) { // A side - chooseOf5Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, deviceTemperatures.mgm0SideA, - sensorTemperatures.sensor_tcs_board); + chooseOf4Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, sensorTemperatures.sensor_tcs_board); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); } // B side - chooseOf5Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, - deviceTemperatures.gyro3SideB, deviceTemperatures.mgm2SideB, - sensorTemperatures.sensor_tcs_board); + chooseOf4Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, + deviceTemperatures.gyro3SideB, sensorTemperatures.sensor_tcs_board); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); } @@ -1151,6 +1148,9 @@ void ThermalController::ctrlObc() { ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs1, sensorTemperatures.tmp1075Tcs0, &obcLimits); + if (componentOverheating) { + triggerEvent(OBC_OVERHEATING); + } } void ThermalController::ctrlObcIfBoard() { @@ -1164,6 +1164,9 @@ void ThermalController::ctrlSBandTransceiver() { deviceTemperatures.syrlinksPowerAmplifier, deviceTemperatures.syrlinksBasebandBoard, sensorTemperatures.sensor_4k_camera, &sBandTransceiverLimits); + if (componentOverheating) { + triggerEvent(SYRLINKS_OVERHEATING); + } } void ThermalController::ctrlPcduP60Board() { ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, @@ -1219,6 +1222,9 @@ void ThermalController::ctrlPlPcduBoard() { sensorTemperatures.sensor_plpcdu_heatspreader); if (sensorTempAvailable) { ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); + if (componentOverheating) { + triggerEvent(PLPCDU_OVERHEATING, switchNr); + } } } } @@ -1228,6 +1234,9 @@ void ThermalController::ctrlPlocMissionBoard() { sensorTemperatures.sensor_ploc_heatspreader, sensorTemperatures.sensor_ploc_missionboard, sensorTemperatures.sensor_dac_heatspreader, &plocMissionBoardLimits); + if (componentOverheating) { + triggerEvent(PLOC_OVERHEATING); + } } void ThermalController::ctrlPlocProcessingBoard() { @@ -1278,6 +1287,9 @@ void ThermalController::ctrlHpa() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, sensorTemperatures.sensor_hpa, sensorTemperatures.sensor_x8, sensorTemperatures.sensor_mpa, &hpaLimits); + if (componentOverheating) { + triggerEvent(HPA_OVERHEATING); + } } void ThermalController::ctrlScexBoard() { @@ -1288,20 +1300,25 @@ void ThermalController::ctrlScexBoard() { void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, struct TempLimits* tempLimit) { + componentOverheating = false; // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { if (sensorTemp < (*tempLimit).opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; } // Heater on } else if (heaterHandler.checkSwitchState(switchNr)) { if (sensorTemp >= (*tempLimit).opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; } } else if (not redSwitchNrInUse) { if (heaterHandler.checkSwitchState(redSwitchNr)) { if (sensorTemp >= (*tempLimit).cutOffLimit) { + componentOverheating = true; heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater" << redSwitchNr << " OFF" << std::endl; } } } @@ -1327,15 +1344,16 @@ void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_ const lp_float_t& sensor2, const lp_float_t& sensor3) { sensorTempAvailable = true; - if (sensor1.isValid()) { + if (sensor1.isValid() and sensor1.value != INVALID_TEMPERATURE) { sensorTemp = sensor1.value; - } else if (sensor2.isValid()) { + } else if (sensor2.isValid() and sensor2.value != INVALID_TEMPERATURE) { sensorTemp = sensor2.value; - } else if (sensor3.isValid()) { + } else if (sensor3.isValid() and sensor3.value != INVALID_TEMPERATURE) { sensorTemp = sensor3.value; } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; @@ -1363,40 +1381,18 @@ void ThermalController::chooseOf4Sensors(heater::Switchers switchNr, const lp_fl const lp_float_t& sensor4) { sensorTempAvailable = true; - if (sensor1.isValid()) { + if (sensor1.isValid() and sensor1.value != INVALID_TEMPERATURE) { sensorTemp = sensor1.value; - } else if (sensor2.isValid()) { + } else if (sensor2.isValid() and sensor2.value != INVALID_TEMPERATURE) { sensorTemp = sensor2.value; - } else if (sensor3.isValid()) { + } else if (sensor3.isValid() and sensor3.value != INVALID_TEMPERATURE) { sensorTemp = sensor3.value; - } else if (sensor4.isValid()) { + } else if (sensor4.isValid() and sensor4.value != INVALID_TEMPERATURE) { sensorTemp = sensor4.value; } else { if (heaterHandler.checkSwitchState(switchNr)) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } -} -void ThermalController::chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, - const lp_float_t& sensor4, const lp_float_t& sensor5) { - sensorTempAvailable = true; - - if (sensor1.isValid()) { - sensorTemp = sensor1.value; - } else if (sensor2.isValid()) { - sensorTemp = sensor2.value; - } else if (sensor3.isValid()) { - sensorTemp = sensor3.value; - } else if (sensor4.isValid()) { - sensorTemp = sensor4.value; - } else if (sensor5.isValid()) { - sensorTemp = sensor5.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1f977524..421d0cb1 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -58,6 +58,11 @@ class ThermalController : public ExtendedControllerBase { 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; @@ -143,6 +148,7 @@ class ThermalController : public ExtendedControllerBase { bool sensorTempAvailable = true; bool heaterAvailable = true; bool redSwitchNrInUse = false; + bool componentOverheating = false; // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); @@ -169,9 +175,6 @@ class ThermalController : public ExtendedControllerBase { void chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, const lp_float_t& sensor2, const lp_float_t& sensor3, const lp_float_t& sensor4); - void chooseOf5Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, - const lp_float_t& sensor4, const lp_float_t& sensor5); void ctrlAcsBoard(); void ctrlMgt(); diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 8fd166f0..43f53bf7 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -7,7 +7,6 @@ #include -#include "devices/gpioIds.h" #include "devices/powerSwitcherList.h" HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, HeaterHelper helper, From f4f07964599a182c2c2dd8d6f9a961ee70b4d873 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Feb 2023 15:52:49 +0100 Subject: [PATCH 54/59] these includes are required --- linux/ObjectFactory.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 0b7580ec..0ee74514 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,8 +9,15 @@ #include #include #include +#include #include +#include #include +#include +#include +#include +#include +#include #include "OBSWConfig.h" #include "devConf.h" @@ -19,6 +26,7 @@ #include "eive/definitions.h" #include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/payloadModeTree.h" +#include "mission/system/tree/tcsModeTree.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, std::string spiDev, @@ -111,8 +119,8 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo fdir = new SusFdir(objects::SUS_5_N_LOC_XFYMZB_PT_ZB); susHandlers[5]->setCustomFdir(fdir); - spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, - spi::SUS_MAX1227_SPI_FREQ); + spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE, + spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); susHandlers[6] = new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SPI_MAIN_COM_IF, spiCookie); fdir = new SusFdir(objects::SUS_6_R_LOC_XFYBZM_PT_XF); From 64e1355e061eebb57649ac0c4bcb9489ba3254a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Feb 2023 15:59:30 +0100 Subject: [PATCH 55/59] cache maps --- dummies/TemperatureSensorInserter.cpp | 15 +++++++-------- dummies/TemperatureSensorInserter.h | 15 +++++++++------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 58748e87..efbec2d0 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -5,23 +5,22 @@ #include #include -TemperatureSensorInserter::TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_) - : SystemObject(objects::THERMAL_TEMP_INSERTER) {} +TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId, + const Max31865DummyMap& tempSensorDummies_, + const Tmp1075DummyMap& tempTmpSensorDummies_) + : SystemObject(objects::THERMAL_TEMP_INSERTER), + max31865DummyMap(tempSensorDummies_), + tmp1075DummyMap(tempTmpSensorDummies_) {} ReturnValue_t TemperatureSensorInserter::initialize() { if (performTest) { - if (testCase == TestCase::OVERCOOL_SYRLINKS) { + if (testCase == TestCase::COOL_SYRLINKS) { } } return returnvalue::OK; } ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { - iteration++; - value = sin(iteration / 80. * M_PI) * 10; - /* ReturnValue_t result = max31865PlocHeatspreaderSet.read(); if (result != returnvalue::OK) { diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index cf858576..ff3f939e 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -8,9 +8,11 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject { public: - explicit TemperatureSensorInserter( - object_id_t objectId, const std::map& tempSensorDummies_, - const std::map& tempTmpSensorDummies_); + using Max31865DummyMap = std::map; + using Tmp1075DummyMap = std::map; + explicit TemperatureSensorInserter(object_id_t objectId, + const Max31865DummyMap& tempSensorDummies_, + const Tmp1075DummyMap& tempTmpSensorDummies_); ReturnValue_t initialize() override; @@ -18,11 +20,12 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject ReturnValue_t performOperation(uint8_t opCode) override; private: - enum TestCase { OVERCOOL_SYRLINKS = 0 }; + Max31865DummyMap max31865DummyMap; + Tmp1075DummyMap tmp1075DummyMap; + enum TestCase { NONE = 0, COOL_SYRLINKS = 1 }; int iteration = 0; bool performTest = false; - float value = 0; - TestCase testCase; + TestCase testCase = TestCase::NONE; // void noise(); }; From 77aff2620439a27dc74c9332c45499d875effa34 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 6 Feb 2023 17:10:09 +0100 Subject: [PATCH 56/59] . --- mission/controller/ThermalController.cpp | 183 +++++++++++------------ mission/controller/ThermalController.h | 34 ++--- 2 files changed, 101 insertions(+), 116 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 8535228a..9eee921f 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -58,7 +58,9 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet8(objects::SUS_8_R_LOC_XBYBZB_PT_YB), susSet9(objects::SUS_9_R_LOC_XBYBZB_PT_YF), susSet10(objects::SUS_10_N_LOC_XMYBZF_PT_ZF), - susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) {} + susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB) { + resetSensorsArray(); +} ReturnValue_t ThermalController::initialize() { auto result = ExtendedControllerBase::initialize(); @@ -113,7 +115,7 @@ void ThermalController::performControlOperation() { ctrlRw(); ctrlStr(); ctrlIfBoard(); - ctrlTcsBoard(); + ctrlAcsBoard(); ctrlObc(); ctrlObcIfBoard(); ctrlSBandTransceiver(); @@ -984,19 +986,17 @@ void ThermalController::copyDevices() { void ThermalController::ctrlAcsBoard() { heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; - chooseHeater(switchNr, redSwitchNr); - if (heaterAvailable) { + if (chooseHeater(switchNr, redSwitchNr)) { // A side - chooseOf4Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, sensorTemperatures.sensor_tcs_board); - if (sensorTempAvailable) { + if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, + deviceTemperatures.gyro1SideA, sensorTemperatures.sensor_tcs_board)) { ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + return; } // B side - chooseOf4Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, - deviceTemperatures.gyro3SideB, sensorTemperatures.sensor_tcs_board); - if (sensorTempAvailable) { + if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, + deviceTemperatures.gyro3SideB, sensorTemperatures.sensor_tcs_board)) { ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); } } @@ -1011,10 +1011,8 @@ void ThermalController::ctrlMgt() { heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - sensorTempAvailable = true; + if (chooseHeater(switchNr, redSwitchNr)) { + bool sensorTempAvailable = true; if (sensorTemperatures.sensor_magnettorquer.isValid()) { sensorTemp = sensorTemperatures.sensor_magnettorquer.value; @@ -1043,7 +1041,7 @@ void ThermalController::ctrlRw() { if (heaterHandler.getHealth(switchNr) == HasHealthIF::HEALTHY) { // RW1 - sensorTempAvailable = true; + bool sensorTempAvailable = true; if (sensorTemperatures.sensor_rw1.isValid()) { sensorTemp = sensorTemperatures.sensor_rw1.value; @@ -1081,7 +1079,7 @@ void ThermalController::ctrlRw() { sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &rwLimits); + ctrlHeater(switchNr, redSwitchNr, rwLimits); } // RW3 sensorTempAvailable = true; @@ -1101,7 +1099,7 @@ void ThermalController::ctrlRw() { sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &rwLimits); + ctrlHeater(switchNr, redSwitchNr, rwLimits); } // RW4 sensorTempAvailable = true; @@ -1121,34 +1119,50 @@ void ThermalController::ctrlRw() { sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &rwLimits); + ctrlHeater(switchNr, redSwitchNr, rwLimits); } } } void ThermalController::ctrlStr() { - ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, - sensorTemperatures.sensor_startracker, deviceTemperatures.startracker, - sensorTemperatures.sensor_dro, &strLimits); + sensors[0].first = sensorTemperatures.sensor_startracker.isValid(); + sensors[0].second = sensorTemperatures.sensor_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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, + strLimits); } void ThermalController::ctrlIfBoard() { - ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, - sensorTemperatures.tmp1075IfBrd, sensorTemperatures.sensor_magnettorquer, - deviceTemperatures.mgm2SideB, &ifBoardLimits); + 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[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); } void ThermalController::ctrlTcsBoard() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, - sensorTemperatures.sensor_tcs_board, sensorTemperatures.tmp1075Tcs0, - sensorTemperatures.tmp1075Tcs1, &tcsBoardLimits); + sensors[0].first = sensorTemperatures.sensor_tcs_board.isValid(); + sensors[0].second = sensorTemperatures.sensor_tcs_board.value; + sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); + sensors[1].second = sensorTemperatures.tmp1075Tcs0.value; + 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); } void ThermalController::ctrlObc() { ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs1, sensorTemperatures.tmp1075Tcs0, &obcLimits); - if (componentOverheating) { + if (componentAboveCutOffLimit) { triggerEvent(OBC_OVERHEATING); } } @@ -1163,25 +1177,23 @@ void ThermalController::ctrlSBandTransceiver() { ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, deviceTemperatures.syrlinksPowerAmplifier, deviceTemperatures.syrlinksBasebandBoard, - sensorTemperatures.sensor_4k_camera, &sBandTransceiverLimits); - if (componentOverheating) { + sensorTemperatures.sensor_4k_camera, sBandTransceiverLimits); + if (componentAboveCutOffLimit) { triggerEvent(SYRLINKS_OVERHEATING); } } void ThermalController::ctrlPcduP60Board() { ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, deviceTemperatures.temp1P60dock, deviceTemperatures.temp2P60dock, - deviceTemperatures.temp2P60dock, &pcduP60BoardLimits); + deviceTemperatures.temp2P60dock, pcduP60BoardLimits); } void ThermalController::ctrlPcduAcu() { heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - sensorTempAvailable = true; + if (chooseHeater(switchNr, redSwitchNr)) { + bool sensorTempAvailable = true; if (deviceTemperatures.acu.value[0] != INVALID_TEMPERATURE) { sensorTemp = deviceTemperatures.acu.value[0]; @@ -1214,15 +1226,12 @@ void ThermalController::ctrlPlPcduBoard() { heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; - chooseHeater(switchNr, redSwitchNr); - - if (heaterAvailable) { - chooseOf4Sensors(switchNr, sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, - deviceTemperatures.adcPayloadPcdu, - sensorTemperatures.sensor_plpcdu_heatspreader); - if (sensorTempAvailable) { + if (chooseHeater(switchNr, redSwitchNr)) { + if (chooseOf4Sensors(switchNr, sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, + deviceTemperatures.adcPayloadPcdu, + sensorTemperatures.sensor_plpcdu_heatspreader)) { ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); - if (componentOverheating) { + if (componentAboveCutOffLimit) { triggerEvent(PLPCDU_OVERHEATING, switchNr); } } @@ -1233,8 +1242,8 @@ void ThermalController::ctrlPlocMissionBoard() { ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, sensorTemperatures.sensor_ploc_heatspreader, sensorTemperatures.sensor_ploc_missionboard, - sensorTemperatures.sensor_dac_heatspreader, &plocMissionBoardLimits); - if (componentOverheating) { + sensorTemperatures.sensor_dac_heatspreader, plocMissionBoardLimits); + if (componentAboveCutOffLimit) { triggerEvent(PLOC_OVERHEATING); } } @@ -1243,7 +1252,7 @@ void ThermalController::ctrlPlocProcessingBoard() { ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, sensorTemperatures.sensor_ploc_missionboard, sensorTemperatures.sensor_ploc_heatspreader, - sensorTemperatures.sensor_dac_heatspreader, &plocProcessingBoardLimits); + sensorTemperatures.sensor_dac_heatspreader, plocProcessingBoardLimits); } void ThermalController::ctrlDac() { @@ -1287,7 +1296,7 @@ void ThermalController::ctrlHpa() { ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, sensorTemperatures.sensor_hpa, sensorTemperatures.sensor_x8, sensorTemperatures.sensor_mpa, &hpaLimits); - if (componentOverheating) { + if (componentAboveCutOffLimit) { triggerEvent(HPA_OVERHEATING); } } @@ -1299,24 +1308,24 @@ void ThermalController::ctrlScexBoard() { } void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, - struct TempLimits* tempLimit) { - componentOverheating = false; + struct TempLimits& tempLimit) { + componentAboveCutOffLimit = false; // Heater off if (not heaterHandler.checkSwitchState(switchNr)) { - if (sensorTemp < (*tempLimit).opLowerLimit) { + if (sensorTemp < tempLimit.opLowerLimit) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::ON); sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " ON" << std::endl; } // Heater on } else if (heaterHandler.checkSwitchState(switchNr)) { - if (sensorTemp >= (*tempLimit).opLowerLimit + TEMP_OFFSET) { + if (sensorTemp >= tempLimit.opLowerLimit + TEMP_OFFSET) { heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; } } else if (not redSwitchNrInUse) { if (heaterHandler.checkSwitchState(redSwitchNr)) { - if (sensorTemp >= (*tempLimit).cutOffLimit) { - componentOverheating = true; + if (sensorTemp >= tempLimit.cutOffLimit) { + componentAboveCutOffLimit = true; heaterHandler.switchHeater(redSwitchNr, HeaterHandler::SwitchState::OFF); sif::info << "ThermalController::ctrlHeater: Heater" << redSwitchNr << " OFF" << std::endl; } @@ -1324,8 +1333,8 @@ void ThermalController::ctrlHeater(heater::Switchers switchNr, heater::Switchers } } -void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { - heaterAvailable = true; +bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr) { + bool heaterAvailable = true; if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { @@ -1338,63 +1347,41 @@ void ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch } else { redSwitchNrInUse = false; } + return heaterAvailable; } -void ThermalController::chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3) { - sensorTempAvailable = true; - - if (sensor1.isValid() and sensor1.value != INVALID_TEMPERATURE) { - sensorTemp = sensor1.value; - } else if (sensor2.isValid() and sensor2.value != INVALID_TEMPERATURE) { - sensorTemp = sensor2.value; - } else if (sensor3.isValid() and sensor3.value != INVALID_TEMPERATURE) { - sensorTemp = sensor3.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; +bool ThermalController::selectAndReadSensorTemp(heater::Switchers switchNr) { + for(unsigned i= 0; i, 5> sensors; + uint8_t numSensors = 0; + PoolEntry tmp1075Tcs0 = PoolEntry(10.0); PoolEntry tmp1075Tcs1 = PoolEntry(10.0); PoolEntry tmp1075PlPcdu0 = PoolEntry(10.0); @@ -161,20 +163,16 @@ class ThermalController : public ExtendedControllerBase { static constexpr dur_millis_t MUTEX_TIMEOUT = 50; + void resetSensorsArray(); void copySensors(); void copySus(); void copyDevices(); void ctrlComponentTemperature(heater::Switchers switchNr, heater::Switchers redSwitchNr, - const lp_float_t& sensor1, const lp_float_t& sensor2, - const lp_float_t& sensor3, TempLimits* tempLimit); - void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits* tempLimit); - void chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); - void chooseSensor(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3); - void chooseOf4Sensors(heater::Switchers switchNr, const lp_float_t& sensor1, - const lp_float_t& sensor2, const lp_float_t& sensor3, - const lp_float_t& sensor4); + TempLimits& tempLimit); + void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits& tempLimit); + bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); + bool selectAndReadSensorTemp(heater::Switchers switchNr); void ctrlAcsBoard(); void ctrlMgt(); From 4f8fdc973f5f96c5d4ebf117c99d429babb143f9 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 6 Feb 2023 21:13:17 +0100 Subject: [PATCH 57/59] thermalController upgrade --- mission/controller/ThermalController.cpp | 236 ++++++++++++++--------- 1 file changed, 145 insertions(+), 91 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 9eee921f..aa49ecb5 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -984,6 +984,7 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { + // TODO: fix heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; @@ -991,13 +992,13 @@ void ThermalController::ctrlAcsBoard() { // A side if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, deviceTemperatures.gyro1SideA, sensorTemperatures.sensor_tcs_board)) { - ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); return; } // B side if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, deviceTemperatures.gyro3SideB, sensorTemperatures.sensor_tcs_board)) { - ctrlHeater(switchNr, redSwitchNr, &acsBoardLimits); + ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); } } } @@ -1008,33 +1009,20 @@ void ThermalController::ctrlMgt() { static_cast(imtqThermalSet.heaterRequest.value); if (heaterReq == ThermalComponentIF::STATE_REQUEST_OPERATIONAL) { - heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; - heater::Switchers redSwitchNr = heater::HEATER_3_PCDU_PDU; - - if (chooseHeater(switchNr, redSwitchNr)) { - bool sensorTempAvailable = true; - - if (sensorTemperatures.sensor_magnettorquer.isValid()) { - sensorTemp = sensorTemperatures.sensor_magnettorquer.value; - } else if (deviceTemperatures.mgt.isValid()) { - sensorTemp = deviceTemperatures.mgt.value; - } else if (sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { - sensorTemp = sensorTemperatures.sensor_plpcdu_heatspreader.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &mgtLimits); - } - } + sensors[0].first = sensorTemperatures.sensor_magnettorquer.isValid(); + sensors[0].second = sensorTemperatures.sensor_magnettorquer.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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, + mgtLimits); } } void ThermalController::ctrlRw() { + //TODO: better solution? heater::Switchers switchNr = heater::HEATER_6_DRO; heater::Switchers redSwitchNr = heater::HEATER_6_DRO; redSwitchNrInUse = false; @@ -1059,7 +1047,7 @@ void ThermalController::ctrlRw() { sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &rwLimits); + ctrlHeater(switchNr, redSwitchNr, rwLimits); } // RW2 sensorTempAvailable = true; @@ -1159,33 +1147,50 @@ void ThermalController::ctrlTcsBoard() { } void ThermalController::ctrlObc() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, - deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs1, - sensorTemperatures.tmp1075Tcs0, &obcLimits); + sensors[0].first = deviceTemperatures.q7s.isValid(); + sensors[0].second = deviceTemperatures.q7s.value; + sensors[1].first = sensorTemperatures.tmp1075Tcs1.isValid(); + sensors[1].second = sensorTemperatures.tmp1075Tcs1.value; + 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); if (componentAboveCutOffLimit) { triggerEvent(OBC_OVERHEATING); } } void ThermalController::ctrlObcIfBoard() { - ctrlComponentTemperature(heater::HEATER_0_OBC_BRD, heater::HEATER_2_ACS_BRD, - deviceTemperatures.q7s, sensorTemperatures.tmp1075Tcs0, - sensorTemperatures.tmp1075Tcs1, &obcIfBoardLimits); + sensors[0].first = deviceTemperatures.q7s.isValid(); + sensors[0].second = deviceTemperatures.q7s.value; + sensors[1].first = sensorTemperatures.tmp1075Tcs0.isValid(); + sensors[1].second = sensorTemperatures.tmp1075Tcs0.value; + 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); } void ThermalController::ctrlSBandTransceiver() { - ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, - deviceTemperatures.syrlinksPowerAmplifier, - deviceTemperatures.syrlinksBasebandBoard, - sensorTemperatures.sensor_4k_camera, sBandTransceiverLimits); + sensors[0].first = deviceTemperatures.syrlinksPowerAmplifier.isValid(); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); if (componentAboveCutOffLimit) { triggerEvent(SYRLINKS_OVERHEATING); } } void ThermalController::ctrlPcduP60Board() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, - deviceTemperatures.temp1P60dock, deviceTemperatures.temp2P60dock, - deviceTemperatures.temp2P60dock, pcduP60BoardLimits); + sensors[0].first = deviceTemperatures.temp1P60dock.isValid(); + sensors[0].second = deviceTemperatures.temp1P60dock.value; + 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); } void ThermalController::ctrlPcduAcu() { @@ -1204,107 +1209,156 @@ void ThermalController::ctrlPcduAcu() { } else if (sensorTemperatures.sensor_acu.isValid()) { sensorTemp = sensorTemperatures.sensor_acu.value; } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); sensorTempAvailable = false; } if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, &pcduAcuLimits); + ctrlHeater(switchNr, redSwitchNr, pcduAcuLimits); } } } void ThermalController::ctrlPcduPdu() { - ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, - deviceTemperatures.pdu1, deviceTemperatures.pdu2, - deviceTemperatures.pdu2, &pcduPduLimits); + sensors[0].first = deviceTemperatures.pdu1.isValid(); + sensors[0].second = deviceTemperatures.pdu1.value; + sensors[1].first = deviceTemperatures.pdu2.isValid(); + sensors[1].second = deviceTemperatures.pdu2.value; + sensors[2].first = sensorTemperatures.tmp1075Tcs0.isValid(); + sensors[2].second = sensorTemperatures.tmp1075Tcs0.value; + numSensors = 2; + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, pcduPduLimits); } void ThermalController::ctrlPlPcduBoard() { - heater::Switchers switchNr = heater::HEATER_3_PCDU_PDU; - heater::Switchers redSwitchNr = heater::HEATER_2_ACS_BRD; - - if (chooseHeater(switchNr, redSwitchNr)) { - if (chooseOf4Sensors(switchNr, sensorTemperatures.tmp1075PlPcdu0, sensorTemperatures.tmp1075PlPcdu1, - deviceTemperatures.adcPayloadPcdu, - sensorTemperatures.sensor_plpcdu_heatspreader)) { - ctrlHeater(switchNr, redSwitchNr, &plPcduBoardLimits); - if (componentAboveCutOffLimit) { - triggerEvent(PLPCDU_OVERHEATING, switchNr); - } - } + sensors[0].first = sensorTemperatures.tmp1075PlPcdu0.isValid(); + sensors[0].second = sensorTemperatures.tmp1075PlPcdu0.value; + sensors[1].first = sensorTemperatures.tmp1075PlPcdu1.isValid(); + 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; + numSensors = 4; + ctrlComponentTemperature(heater::HEATER_3_PCDU_PDU, heater::HEATER_2_ACS_BRD, plPcduBoardLimits); + if (componentAboveCutOffLimit) { + triggerEvent(PLPCDU_OVERHEATING); } } void ThermalController::ctrlPlocMissionBoard() { - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, - sensorTemperatures.sensor_ploc_heatspreader, - sensorTemperatures.sensor_ploc_missionboard, - sensorTemperatures.sensor_dac_heatspreader, plocMissionBoardLimits); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocMissionBoardLimits); if (componentAboveCutOffLimit) { triggerEvent(PLOC_OVERHEATING); } } void ThermalController::ctrlPlocProcessingBoard() { - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, - sensorTemperatures.sensor_ploc_missionboard, - sensorTemperatures.sensor_ploc_heatspreader, - sensorTemperatures.sensor_dac_heatspreader, plocProcessingBoardLimits); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocProcessingBoardLimits); } void ThermalController::ctrlDac() { - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, - sensorTemperatures.sensor_dac_heatspreader, - sensorTemperatures.sensor_ploc_missionboard, - sensorTemperatures.sensor_ploc_heatspreader, &dacLimits); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, dacLimits); } void ThermalController::ctrlCameraBody() { - ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, - sensorTemperatures.sensor_4k_camera, sensorTemperatures.sensor_dro, - sensorTemperatures.sensor_mpa, &cameraLimits); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_4_CAMERA, heater::HEATER_6_DRO, cameraLimits); } void ThermalController::ctrlDro() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, - sensorTemperatures.sensor_dro, sensorTemperatures.sensor_4k_camera, - sensorTemperatures.sensor_mpa, &droLimits); + 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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, droLimits); } void ThermalController::ctrlX8() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, - sensorTemperatures.sensor_x8, sensorTemperatures.sensor_hpa, - sensorTemperatures.sensor_tx_modul, &x8Limits); + 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[2].first = sensorTemperatures.sensor_tx_modul.isValid(); + sensors[2].second = sensorTemperatures.sensor_tx_modul.value; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, x8Limits); } void ThermalController::ctrlTx() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, - sensorTemperatures.sensor_tx_modul, sensorTemperatures.sensor_x8, - sensorTemperatures.sensor_mpa, &txLimits); + sensors[0].first = sensorTemperatures.sensor_tx_modul.isValid(); + sensors[0].second = sensorTemperatures.sensor_tx_modul.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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, txLimits); } void ThermalController::ctrlMpa() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, - sensorTemperatures.sensor_mpa, sensorTemperatures.sensor_hpa, - sensorTemperatures.sensor_tx_modul, &mpaLimits); + sensors[0].first = sensorTemperatures.sensor_mpa.isValid(); + sensors[0].second = sensorTemperatures.sensor_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; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, mpaLimits); } void ThermalController::ctrlHpa() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, - sensorTemperatures.sensor_hpa, sensorTemperatures.sensor_x8, - sensorTemperatures.sensor_mpa, &hpaLimits); + 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[2].first = sensorTemperatures.sensor_mpa.isValid(); + sensors[2].second = sensorTemperatures.sensor_mpa.value; + numSensors = 3; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_4_CAMERA, hpaLimits); if (componentAboveCutOffLimit) { triggerEvent(HPA_OVERHEATING); } } void ThermalController::ctrlScexBoard() { - ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_5_STR, - sensorTemperatures.sensor_scex, sensorTemperatures.sensor_x8, - sensorTemperatures.sensor_hpa, &scexBoardLimits); + 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, From 9cf65be1be3e8e74b53e8d6e401b4b5fb57ed04e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 7 Feb 2023 14:28:42 +0100 Subject: [PATCH 58/59] ThermalController upgrade --- mission/controller/ThermalController.cpp | 230 +++++++++++------------ mission/controller/ThermalController.h | 9 +- 2 files changed, 114 insertions(+), 125 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index aa49ecb5..a0b710fc 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -984,23 +984,50 @@ void ThermalController::copyDevices() { } void ThermalController::ctrlAcsBoard() { - // TODO: fix + // TODO: check heater::Switchers switchNr = heater::HEATER_2_ACS_BRD; heater::Switchers redSwitchNr = heater::HEATER_0_OBC_BRD; - if (chooseHeater(switchNr, redSwitchNr)) { - // A side - if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro0SideA, deviceTemperatures.mgm0SideA, - deviceTemperatures.gyro1SideA, sensorTemperatures.sensor_tcs_board)) { + // A side + 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; + if (selectAndReadSensorTemp()) { + if (chooseHeater(switchNr, redSwitchNr)) { ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); - return; } - // B side - if (chooseOf4Sensors(switchNr, deviceTemperatures.gyro2SideB, deviceTemperatures.mgm2SideB, - deviceTemperatures.gyro3SideB, sensorTemperatures.sensor_tcs_board)) { + resetSensorsArray(); + return; + } + + // B side + sensors[0].first = deviceTemperatures.gyro2SideB.isValid(); + sensors[0].second = deviceTemperatures.gyro2SideB.value; + sensors[1].first = deviceTemperatures.mgm2SideB.isValid(); + 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; + if (selectAndReadSensorTemp()) { + if (chooseHeater(switchNr, redSwitchNr)) { ctrlHeater(switchNr, redSwitchNr, acsBoardLimits); } + } else { + if (chooseHeater(switchNr, redSwitchNr)) { + if (heaterHandler.checkSwitchState(switchNr)) { + heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); + sif::info << "ThermalController::ctrlHeater: Heater" << switchNr << " OFF" << std::endl; + } + } } + resetSensorsArray(); } void ThermalController::ctrlMgt() { @@ -1016,100 +1043,59 @@ void ThermalController::ctrlMgt() { sensors[2].first = sensorTemperatures.sensor_plpcdu_heatspreader.isValid(); sensors[2].second = sensorTemperatures.sensor_plpcdu_heatspreader.value; numSensors = 3; - ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, - mgtLimits); + ctrlComponentTemperature(heater::HEATER_2_ACS_BRD, heater::HEATER_3_PCDU_PDU, mgtLimits); } } void ThermalController::ctrlRw() { - //TODO: better solution? - heater::Switchers switchNr = heater::HEATER_6_DRO; - heater::Switchers redSwitchNr = heater::HEATER_6_DRO; - redSwitchNrInUse = false; + // TODO: better solution? + // RW1 + sensors[0].first = sensorTemperatures.sensor_rw1.isValid(); + sensors[0].second = sensorTemperatures.sensor_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; + numSensors = 4; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); - if (heaterHandler.getHealth(switchNr) == HasHealthIF::HEALTHY) { - // RW1 - bool sensorTempAvailable = true; + // RW2 + sensors[0].first = deviceTemperatures.rw2.isValid(); + 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; + numSensors = 4; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); - if (sensorTemperatures.sensor_rw1.isValid()) { - sensorTemp = sensorTemperatures.sensor_rw1.value; - } else if (deviceTemperatures.rw1.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw1.value); - } else if (deviceTemperatures.rw4.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw4.value); - } else if (sensorTemperatures.sensor_dro.isValid()) { - sensorTemp = sensorTemperatures.sensor_dro.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, rwLimits); - } - // RW2 - sensorTempAvailable = true; - if (deviceTemperatures.rw2.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw2.value); - } else if (deviceTemperatures.rw3.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw3.value); - } else if (sensorTemperatures.sensor_rw1.isValid()) { - sensorTemp = sensorTemperatures.sensor_rw1.value; - } else if (sensorTemperatures.sensor_dro.isValid()) { - sensorTemp = sensorTemperatures.sensor_dro.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, rwLimits); - } - // RW3 - sensorTempAvailable = true; - if (deviceTemperatures.rw3.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw3.value); - } else if (deviceTemperatures.rw4.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw4.value); - } else if (sensorTemperatures.sensor_rw1.isValid()) { - sensorTemp = sensorTemperatures.sensor_rw1.value; - } else if (sensorTemperatures.sensor_dro.isValid()) { - sensorTemp = sensorTemperatures.sensor_dro.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, rwLimits); - } - // RW4 - sensorTempAvailable = true; - if (deviceTemperatures.rw4.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw4.value); - } else if (deviceTemperatures.rw1.isValid()) { - sensorTemp = static_cast(deviceTemperatures.rw1.value); - } else if (sensorTemperatures.sensor_rw1.isValid()) { - sensorTemp = sensorTemperatures.sensor_rw1.value; - } else if (sensorTemperatures.sensor_dro.isValid()) { - sensorTemp = sensorTemperatures.sensor_dro.value; - } else { - if (heaterHandler.checkSwitchState(switchNr)) { - heaterHandler.switchHeater(switchNr, HeaterHandler::SwitchState::OFF); - } - triggerEvent(NO_VALID_SENSOR_TEMPERATURE, switchNr); - sensorTempAvailable = false; - } - if (sensorTempAvailable) { - ctrlHeater(switchNr, redSwitchNr, rwLimits); - } - } + // RW3 + sensors[0].first = deviceTemperatures.rw3.isValid(); + 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; + numSensors = 4; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); + + // RW4 + sensors[0].first = deviceTemperatures.rw4.isValid(); + 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; + numSensors = 4; + ctrlComponentTemperature(heater::HEATER_6_DRO, heater::HEATER_6_DRO, rwLimits); } void ThermalController::ctrlStr() { @@ -1120,18 +1106,17 @@ void ThermalController::ctrlStr() { sensors[2].first = sensorTemperatures.sensor_dro.isValid(); sensors[2].second = sensorTemperatures.sensor_dro.value; numSensors = 3; - ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, - strLimits); + ctrlComponentTemperature(heater::HEATER_5_STR, heater::HEATER_6_DRO, strLimits); } void ThermalController::ctrlIfBoard() { - 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[2].first = deviceTemperatures.mgm2SideB.isValid(); - sensors[2].second = deviceTemperatures.mgm2SideB.value; - numSensors = 3; + 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[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); } @@ -1179,7 +1164,8 @@ void ThermalController::ctrlSBandTransceiver() { sensors[2].first = sensorTemperatures.sensor_4k_camera.isValid(); sensors[2].second = sensorTemperatures.sensor_4k_camera.value; numSensors = 3; - ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, sBandTransceiverLimits); + ctrlComponentTemperature(heater::HEATER_7_S_BAND, heater::HEATER_4_CAMERA, + sBandTransceiverLimits); if (componentAboveCutOffLimit) { triggerEvent(SYRLINKS_OVERHEATING); } @@ -1253,7 +1239,8 @@ void ThermalController::ctrlPlocMissionBoard() { sensors[2].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); sensors[2].second = sensorTemperatures.sensor_dac_heatspreader.value; numSensors = 3; - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocMissionBoardLimits); + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, + plocMissionBoardLimits); if (componentAboveCutOffLimit) { triggerEvent(PLOC_OVERHEATING); } @@ -1267,7 +1254,8 @@ void ThermalController::ctrlPlocProcessingBoard() { sensors[2].first = sensorTemperatures.sensor_dac_heatspreader.isValid(); sensors[2].second = sensorTemperatures.sensor_dac_heatspreader.value; numSensors = 3; - ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, plocProcessingBoardLimits); + ctrlComponentTemperature(heater::HEATER_1_PLOC_PROC_BRD, heater::HEATER_0_OBC_BRD, + plocProcessingBoardLimits); } void ThermalController::ctrlDac() { @@ -1404,37 +1392,39 @@ bool ThermalController::chooseHeater(heater::Switchers& switchNr, heater::Switch return heaterAvailable; } -bool ThermalController::selectAndReadSensorTemp(heater::Switchers switchNr) { - for(unsigned i= 0; i, 5> sensors; + std::array, 5> sensors; uint8_t numSensors = 0; PoolEntry tmp1075Tcs0 = PoolEntry(10.0); @@ -172,7 +171,7 @@ class ThermalController : public ExtendedControllerBase { TempLimits& tempLimit); void ctrlHeater(heater::Switchers switchNr, heater::Switchers redSwitchNr, TempLimits& tempLimit); bool chooseHeater(heater::Switchers& switchNr, heater::Switchers redSwitchNr); - bool selectAndReadSensorTemp(heater::Switchers switchNr); + bool selectAndReadSensorTemp(); void ctrlAcsBoard(); void ctrlMgt(); From fddfa80f765f1ca018d1eca32c20a4fcf96ada2f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 16:58:32 +0100 Subject: [PATCH 59/59] fix unittest --- unittest/controller/testThermalController.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 87c6ee12..302a18c4 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -7,7 +7,7 @@ #include -#include "../../dummies/TemperatureSensorInserter.h" +#include "dummies/TemperatureSensorInserter.h" #include "../testEnvironment.h" #include "mission/core/GenericFactory.h" #include "test/gpio/DummyGpioIF.h" @@ -15,7 +15,9 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; - new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER); + TemperatureSensorInserter::Max31865DummyMap map0; + TemperatureSensorInserter::Tmp1075DummyMap map1; + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, map0, map1); auto dummyGpioIF = new DummyGpioIF(); auto dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); // TODO: Create dummy heater handler