#include "ThermalController.h" #include #include ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) : ExtendedControllerBase(objectId, parentId), sensorTemperatures(this), susTemperatures(this), deviceTemperatures(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), tmp1075Set1(objects::TMP1075_HANDLER_1), tmp1075Set2(objects::TMP1075_HANDLER_2), susSet0(objects::SUS_0_N_LOC_XFYFZM_PT_XF), susSet1(objects::SUS_1_N_LOC_XBYFZM_PT_XB), susSet2(objects::SUS_2_N_LOC_XFYBZB_PT_YB), susSet3(objects::SUS_3_N_LOC_XFYBZF_PT_YF), susSet4(objects::SUS_4_N_LOC_XMYFZF_PT_ZF), susSet5(objects::SUS_5_N_LOC_XFYMZB_PT_ZB), susSet6(objects::SUS_6_R_LOC_XFYBZM_PT_XF), susSet7(objects::SUS_7_R_LOC_XBYBZM_PT_XB), 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) {} ReturnValue_t ThermalController::initialize() { auto result = ExtendedControllerBase::initialize(); return result; } ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { return RETURN_FAILED; } void ThermalController::performControlOperation() { ReturnValue_t result = sensorTemperatures.read(); if (result == RETURN_OK) { copySensors(); sensorTemperatures.commit(); } result = susTemperatures.read(); if (result == RETURN_OK) { copySus(); susTemperatures.commit(); } result = deviceTemperatures.read(); if (result == RETURN_OK) { copyDevices(); deviceTemperatures.commit(); } result = componentTemperatures.read(); if (result != RETURN_OK) { return; } componentTemperatures.commit(); } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLOC_HEATSPREADER, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLOC_MISSIONBOARD, new PoolEntry({1.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_4K_CAMERA, new PoolEntry({2.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_DAC_HEATSPREADER, new PoolEntry({3.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_STARTRACKER, new PoolEntry({4.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_RW1, new PoolEntry({5.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_DRO, new PoolEntry({6.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_SCEX, new PoolEntry({7.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_X8, new PoolEntry({8.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_HPA, new PoolEntry({9.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TX_MODUL, new PoolEntry({10.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_MPA, new PoolEntry({11.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_ACU, new PoolEntry({12.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLPCDU_HEATSPREADER, new PoolEntry({13.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TCS_BOARD, new PoolEntry({14.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_MAGNETTORQUER, new PoolEntry({15.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_1, new PoolEntry({15.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_2, new PoolEntry({15.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_0_N_LOC_XFYFZM_PT_XF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_6_R_LOC_XFYBZM_PT_XF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_1_N_LOC_XBYFZM_PT_XB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_7_R_LOC_XBYBZM_PT_XB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_2_N_LOC_XFYBZB_PT_YB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_8_R_LOC_XBYBZB_PT_YB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_3_N_LOC_XFYBZF_PT_YF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_9_R_LOC_XBYBZB_PT_YF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_4_N_LOC_XMYFZF_PT_ZF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_10_N_LOC_XMYBZF_PT_ZF, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_5_N_LOC_XFYMZB_PT_ZB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::SUS_11_R_LOC_XBYMZB_PT_ZB, new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::COMPONENT_RW, new PoolEntry({0.0})); poolManager.subscribeForPeriodicPacket(sensorTemperatures.getSid(), true, 1.0, false); poolManager.subscribeForPeriodicPacket(susTemperatures.getSid(), true, 1.0, false); return RETURN_OK; } LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { switch (sid.ownerSetId) { case thermalControllerDefinitions::SENSOR_TEMPERATURES: return &sensorTemperatures; case thermalControllerDefinitions::SUS_TEMPERATURES: return &susTemperatures; default: return nullptr; } } ReturnValue_t ThermalController::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 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()); if (not sensorTemperatures.sensor_ploc_heatspreader.isValid()) { sensorTemperatures.sensor_ploc_heatspreader.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_ploc_missionboard.isValid()) { sensorTemperatures.sensor_ploc_missionboard.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_4k_camera.isValid()) { sensorTemperatures.sensor_4k_camera.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_dac_heatspreader.isValid()) { sensorTemperatures.sensor_dac_heatspreader.value = INVALID_TEMPERATURE; } } PoolReadGuard pg4(&max31865Set4); if (pg4.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_startracker.value = max31865Set4.temperatureCelcius.value; sensorTemperatures.sensor_startracker.setValid(max31865Set4.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_startracker.isValid()) { sensorTemperatures.sensor_startracker.value = INVALID_TEMPERATURE; } } PoolReadGuard pg5(&max31865Set5); if (pg5.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_rw1.value = max31865Set5.temperatureCelcius.value; sensorTemperatures.sensor_rw1.setValid(max31865Set5.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_rw1.isValid()) { sensorTemperatures.sensor_rw1.value = INVALID_TEMPERATURE; } } PoolReadGuard pg6(&max31865Set6); if (pg6.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_dro.value = max31865Set6.temperatureCelcius.value; sensorTemperatures.sensor_dro.setValid(max31865Set6.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_dro.isValid()) { sensorTemperatures.sensor_dro.value = INVALID_TEMPERATURE; } } PoolReadGuard pg7(&max31865Set7); if (pg7.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_scex.value = max31865Set7.temperatureCelcius.value; sensorTemperatures.sensor_scex.setValid(max31865Set7.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_scex.isValid()) { sensorTemperatures.sensor_scex.value = INVALID_TEMPERATURE; } } PoolReadGuard pg8(&max31865Set8); if (pg8.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_x8.value = max31865Set8.temperatureCelcius.value; sensorTemperatures.sensor_x8.setValid(max31865Set8.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_x8.isValid()) { sensorTemperatures.sensor_x8.value = INVALID_TEMPERATURE; } } PoolReadGuard pg9(&max31865Set9); if (pg9.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_hpa.value = max31865Set9.temperatureCelcius.value; sensorTemperatures.sensor_hpa.setValid(max31865Set9.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_hpa.isValid()) { sensorTemperatures.sensor_hpa.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_tx_modul.isValid()) { sensorTemperatures.sensor_tx_modul.value = INVALID_TEMPERATURE; } } PoolReadGuard pg11(&max31865Set11); if (pg11.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_mpa.value = max31865Set11.temperatureCelcius.value; sensorTemperatures.sensor_mpa.setValid(max31865Set11.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_mpa.isValid()) { sensorTemperatures.sensor_mpa.value = INVALID_TEMPERATURE; } } PoolReadGuard pg12(&max31865Set12); if (pg12.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_acu.value = max31865Set12.temperatureCelcius.value; sensorTemperatures.sensor_acu.setValid(max31865Set12.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_acu.isValid()) { sensorTemperatures.sensor_acu.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_plpcdu_heatspreader.isValid()) { sensorTemperatures.sensor_plpcdu_heatspreader.value = INVALID_TEMPERATURE; } } 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()); if (not sensorTemperatures.sensor_tcs_board.isValid()) { sensorTemperatures.sensor_tcs_board.value = INVALID_TEMPERATURE; } } PoolReadGuard pg15(&max31865Set15); if (pg15.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_magnettorquer.value = max31865Set15.temperatureCelcius.value; sensorTemperatures.sensor_magnettorquer.setValid(max31865Set15.temperatureCelcius.isValid()); if (not sensorTemperatures.sensor_magnettorquer.isValid()) { sensorTemperatures.sensor_magnettorquer.value = INVALID_TEMPERATURE; } } PoolReadGuard pg111(&tmp1075Set1); if (pg1.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_tmp1075_1.value = tmp1075Set1.temperatureCelcius.value; sensorTemperatures.sensor_tmp1075_1.setValid(tmp1075Set1.temperatureCelcius.isValid()); if (not tmp1075Set1.temperatureCelcius.isValid()) { sensorTemperatures.sensor_tmp1075_1.value = INVALID_TEMPERATURE; } } PoolReadGuard pg112(&tmp1075Set2); if (pg2.getReadResult() == HasReturnvaluesIF::RETURN_OK) { sensorTemperatures.sensor_tmp1075_2.value = tmp1075Set2.temperatureCelcius.value; sensorTemperatures.sensor_tmp1075_2.setValid(tmp1075Set2.temperatureCelcius.isValid()); if (not tmp1075Set2.temperatureCelcius.isValid()) { sensorTemperatures.sensor_tmp1075_2.value = INVALID_TEMPERATURE; } } } void ThermalController::copySus() { PoolReadGuard pg0(&susSet0); if (pg0.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.value = susSet0.temperatureCelcius.value; susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.setValid(susSet0.temperatureCelcius.isValid()); if (not susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.isValid()) { susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg1(&susSet1); if (pg1.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_6_r_loc_xfybzm_pt_xf.value = susSet1.temperatureCelcius.value; susTemperatures.sus_6_r_loc_xfybzm_pt_xf.setValid(susSet1.temperatureCelcius.isValid()); if (not susTemperatures.sus_6_r_loc_xfybzm_pt_xf.isValid()) { susTemperatures.sus_6_r_loc_xfybzm_pt_xf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg2(&susSet2); if (pg2.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.value = susSet2.temperatureCelcius.value; susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.setValid(susSet2.temperatureCelcius.isValid()); if (not susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.isValid()) { susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.value = INVALID_TEMPERATURE; } } PoolReadGuard pg3(&susSet3); if (pg3.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_7_r_loc_xbybzm_pt_xb.value = susSet3.temperatureCelcius.value; susTemperatures.sus_7_r_loc_xbybzm_pt_xb.setValid(susSet3.temperatureCelcius.isValid()); if (not susTemperatures.sus_7_r_loc_xbybzm_pt_xb.isValid()) { susTemperatures.sus_7_r_loc_xbybzm_pt_xb.value = INVALID_TEMPERATURE; } } PoolReadGuard pg4(&susSet4); if (pg4.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_2_n_loc_xfybzb_pt_yb.value = susSet4.temperatureCelcius.value; susTemperatures.sus_2_n_loc_xfybzb_pt_yb.setValid(susSet4.temperatureCelcius.isValid()); if (not susTemperatures.sus_2_n_loc_xfybzb_pt_yb.isValid()) { susTemperatures.sus_2_n_loc_xfybzb_pt_yb.value = INVALID_TEMPERATURE; } } PoolReadGuard pg5(&susSet5); if (pg5.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_8_r_loc_xbybzb_pt_yb.value = susSet5.temperatureCelcius.value; susTemperatures.sus_8_r_loc_xbybzb_pt_yb.setValid(susSet5.temperatureCelcius.isValid()); if (not susTemperatures.sus_8_r_loc_xbybzb_pt_yb.isValid()) { susTemperatures.sus_8_r_loc_xbybzb_pt_yb.value = INVALID_TEMPERATURE; } } PoolReadGuard pg6(&susSet6); if (pg6.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_3_n_loc_xfybzf_pt_yf.value = susSet6.temperatureCelcius.value; susTemperatures.sus_3_n_loc_xfybzf_pt_yf.setValid(susSet6.temperatureCelcius.isValid()); if (not susTemperatures.sus_3_n_loc_xfybzf_pt_yf.isValid()) { susTemperatures.sus_3_n_loc_xfybzf_pt_yf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg7(&susSet7); if (pg7.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_9_r_loc_xbybzb_pt_yf.value = susSet7.temperatureCelcius.value; susTemperatures.sus_9_r_loc_xbybzb_pt_yf.setValid(susSet7.temperatureCelcius.isValid()); if (not susTemperatures.sus_9_r_loc_xbybzb_pt_yf.isValid()) { susTemperatures.sus_9_r_loc_xbybzb_pt_yf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg8(&susSet8); if (pg8.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.value = susSet8.temperatureCelcius.value; susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.setValid(susSet8.temperatureCelcius.isValid()); if (not susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.isValid()) { susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg9(&susSet9); if (pg9.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_10_n_loc_xmybzf_pt_zf.value = susSet9.temperatureCelcius.value; susTemperatures.sus_10_n_loc_xmybzf_pt_zf.setValid(susSet9.temperatureCelcius.isValid()); if (not susTemperatures.sus_10_n_loc_xmybzf_pt_zf.isValid()) { susTemperatures.sus_10_n_loc_xmybzf_pt_zf.value = INVALID_TEMPERATURE; } } PoolReadGuard pg10(&susSet10); if (pg10.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_5_n_loc_xfymzb_pt_zb.value = susSet10.temperatureCelcius.value; susTemperatures.sus_5_n_loc_xfymzb_pt_zb.setValid(susSet10.temperatureCelcius.isValid()); if (not susTemperatures.sus_5_n_loc_xfymzb_pt_zb.isValid()) { susTemperatures.sus_5_n_loc_xfymzb_pt_zb.value = INVALID_TEMPERATURE; } } PoolReadGuard pg11(&susSet11); if (pg11.getReadResult() == HasReturnvaluesIF::RETURN_OK) { susTemperatures.sus_11_r_loc_xbymzb_pt_zb.value = susSet11.temperatureCelcius.value; susTemperatures.sus_11_r_loc_xbymzb_pt_zb.setValid(susSet11.temperatureCelcius.isValid()); if (not susTemperatures.sus_11_r_loc_xbymzb_pt_zb.isValid()) { susTemperatures.sus_11_r_loc_xbymzb_pt_zb.value = INVALID_TEMPERATURE; } } } void ThermalController::copyDevices() {}