From 2f8f5ce79b92bb5740cdc86cb7657f2185658b80 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 19 May 2022 23:08:54 +0200 Subject: [PATCH] thermal controller is reading pt1000 values from datapool --- mission/controller/ThermalController.cpp | 129 ++++++++++++++++++++++- mission/controller/ThermalController.h | 23 +++- 2 files changed, 148 insertions(+), 4 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 2b61a7cb..5969af81 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,9 +1,28 @@ #include "ThermalController.h" +#include +#include + ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) : ExtendedControllerBase(objectId, parentId), sensorTemperatures(this), - componentTemperatures(this) {} + componentTemperatures(this), + max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER), + max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD), + max31865Set2(objects::RTD_2_IC5_4K_CAMERA), + max31865Set3(objects::RTD_3_IC6_DAC_HEATSPREADER), + max31865Set4(objects::RTD_4_IC7_STARTRACKER), + max31865Set5(objects::RTD_5_IC8_RW1_MX_MY), + max31865Set6(objects::RTD_6_IC9_DRO), + max31865Set7(objects::RTD_7_IC10_SCEX), + max31865Set8(objects::RTD_8_IC11_X8), + max31865Set9(objects::RTD_9_IC12_HPA), + max31865Set10(objects::RTD_10_IC13_PL_TX), + max31865Set11(objects::RTD_11_IC14_MPA), + max31865Set12(objects::RTD_12_IC15_ACU), + max31865Set13(objects::RTD_13_IC16_PLPCDU_HEATSPREADER), + max31865Set14(objects::RTD_14_IC17_TCS_BOARD), + max31865Set15(objects::RTD_15_IC18_IMTQ) {} ReturnValue_t ThermalController::initialize() { auto result = ExtendedControllerBase::initialize(); @@ -14,17 +33,21 @@ ReturnValue_t ThermalController::initialize() { ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { return RETURN_FAILED; } + void ThermalController::performControlOperation() { ReturnValue_t result = sensorTemperatures.read(); if (result != RETURN_OK) { return; } + + copySensors(); + result = componentTemperatures.read(); if (result != RETURN_OK) { return; } - sensorTemperatures.sensor_ploc_heatspreader = + /*sensorTemperatures.sensor_ploc_heatspreader = ((int)sensorTemperatures.sensor_ploc_heatspreader.value + 1) % 100; sensorTemperatures.sensor_ploc_missionboard = ((int)sensorTemperatures.sensor_ploc_missionboard.value + 2) % 100; @@ -45,7 +68,7 @@ void ThermalController::performControlOperation() { ((int)sensorTemperatures.sensor_plpcdu_heatspreader.value + 10) % 100; sensorTemperatures.sensor_tcs_board = ((int)sensorTemperatures.sensor_tcs_board.value + 10) % 100; sensorTemperatures.sensor_magnettorquer = - ((int)sensorTemperatures.sensor_magnettorquer.value + 10) % 100; + ((int)sensorTemperatures.sensor_magnettorquer.value + 10) % 100;*/ sensorTemperatures.commit(); componentTemperatures.commit(); @@ -107,3 +130,103 @@ ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode } return RETURN_OK; } + +void ThermalController::copySensors() { + + PoolReadGuard pg0(&max31865Set0); + if (pg0.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_ploc_heatspreader.value = max31865Set0.temperatureCelcius.value; + sensorTemperatures.sensor_ploc_heatspreader.setValid(max31865Set0.temperatureCelcius.isValid()); + } + + PoolReadGuard pg1(&max31865Set1); + if (pg1.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_ploc_missionboard.value = max31865Set1.temperatureCelcius.value; + sensorTemperatures.sensor_ploc_missionboard.setValid(max31865Set1.temperatureCelcius.isValid()); + } + + PoolReadGuard pg2(&max31865Set2); + if (pg2.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_4k_camera.value = max31865Set2.temperatureCelcius.value; + sensorTemperatures.sensor_4k_camera.setValid(max31865Set2.temperatureCelcius.isValid()); + } + + PoolReadGuard pg3(&max31865Set3); + if (pg3.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_dac_heatspreader.value = max31865Set3.temperatureCelcius.value; + sensorTemperatures.sensor_dac_heatspreader.setValid(max31865Set3.temperatureCelcius.isValid()); + } + + PoolReadGuard pg4(&max31865Set4); + if (pg4.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_startracker.value = max31865Set4.temperatureCelcius.value; + sensorTemperatures.sensor_startracker.setValid(max31865Set4.temperatureCelcius.isValid()); + } + + PoolReadGuard pg5(&max31865Set5); + if (pg5.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_rw1.value = max31865Set5.temperatureCelcius.value; + sensorTemperatures.sensor_rw1.setValid(max31865Set5.temperatureCelcius.isValid()); + } + + PoolReadGuard pg6(&max31865Set6); + if (pg6.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_dro.value = max31865Set6.temperatureCelcius.value; + sensorTemperatures.sensor_dro.setValid(max31865Set6.temperatureCelcius.isValid()); + } + + PoolReadGuard pg7(&max31865Set7); + if (pg7.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_scex.value = max31865Set7.temperatureCelcius.value; + sensorTemperatures.sensor_scex.setValid(max31865Set7.temperatureCelcius.isValid()); + } + + PoolReadGuard pg8(&max31865Set8); + if (pg8.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_x8.value = max31865Set8.temperatureCelcius.value; + sensorTemperatures.sensor_x8.setValid(max31865Set8.temperatureCelcius.isValid()); + } + + PoolReadGuard pg9(&max31865Set9); + if (pg9.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_hpa.value = max31865Set9.temperatureCelcius.value; + sensorTemperatures.sensor_hpa.setValid(max31865Set9.temperatureCelcius.isValid()); + } + + PoolReadGuard pg10(&max31865Set10); + if (pg10.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_tx_modul.value = max31865Set10.temperatureCelcius.value; + sensorTemperatures.sensor_tx_modul.setValid(max31865Set10.temperatureCelcius.isValid()); + } + + PoolReadGuard pg11(&max31865Set11); + if (pg11.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_mpa.value = max31865Set11.temperatureCelcius.value; + sensorTemperatures.sensor_mpa.setValid(max31865Set11.temperatureCelcius.isValid()); + } + + PoolReadGuard pg12(&max31865Set12); + if (pg12.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_acu.value = max31865Set12.temperatureCelcius.value; + sensorTemperatures.sensor_acu.setValid(max31865Set12.temperatureCelcius.isValid()); + } + + PoolReadGuard pg13(&max31865Set13); + if (pg13.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_plpcdu_heatspreader.value = max31865Set13.temperatureCelcius.value; + sensorTemperatures.sensor_plpcdu_heatspreader.setValid( + max31865Set13.temperatureCelcius.isValid()); + } + + PoolReadGuard pg14(&max31865Set14); + if (pg14.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_tcs_board.value = max31865Set14.temperatureCelcius.value; + sensorTemperatures.sensor_tcs_board.setValid(max31865Set14.temperatureCelcius.isValid()); + } + + PoolReadGuard pg15(&max31865Set15); + if (pg15.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + sensorTemperatures.sensor_magnettorquer.value = max31865Set15.temperatureCelcius.value; + sensorTemperatures.sensor_magnettorquer.setValid(max31865Set15.temperatureCelcius.isValid()); + } +} \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index e7ffeb79..ad7439f6 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -3,12 +3,14 @@ #include #include +#include class ThermalController : public ExtendedControllerBase { public: ThermalController(object_id_t objectId, object_id_t parentId); ReturnValue_t initialize() override; + protected: virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; @@ -21,9 +23,28 @@ class ThermalController : public ExtendedControllerBase { virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; - private: + private: thermalControllerDefinitions::SensorTemperatures sensorTemperatures; thermalControllerDefinitions::ComponentTemperatures componentTemperatures; + + Max31865Definitions::Max31865Set max31865Set0; + Max31865Definitions::Max31865Set max31865Set1; + Max31865Definitions::Max31865Set max31865Set2; + Max31865Definitions::Max31865Set max31865Set3; + Max31865Definitions::Max31865Set max31865Set4; + Max31865Definitions::Max31865Set max31865Set5; + Max31865Definitions::Max31865Set max31865Set6; + Max31865Definitions::Max31865Set max31865Set7; + Max31865Definitions::Max31865Set max31865Set8; + Max31865Definitions::Max31865Set max31865Set9; + Max31865Definitions::Max31865Set max31865Set10; + Max31865Definitions::Max31865Set max31865Set11; + Max31865Definitions::Max31865Set max31865Set12; + Max31865Definitions::Max31865Set max31865Set13; + Max31865Definitions::Max31865Set max31865Set14; + Max31865Definitions::Max31865Set max31865Set15; + + void copySensors(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */