From 582c8e8eff8cb48ffa04625efcb42c0fd21fb9fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 02:28:57 +0100 Subject: [PATCH] some more fixes so heater info works --- mission/controller/ThermalController.cpp | 11 +++++++--- .../ThermalControllerDefinitions.h | 2 +- mission/devices/HeaterHandler.cpp | 22 +++++++++++++------ mission/devices/HeaterHandler.h | 3 ++- tmtc | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 70c96734..235ad83e 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -113,11 +113,16 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } + std::array heaterStates; + heaterHandler.getAllSwitchStates(heaterStates); { PoolReadGuard pg(&heaterInfo); - PoolReadGuard pg2(¤tVecPdu2); - if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { - heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + std::memcpy(heaterInfo.heaterSwitchState.value, heaterStates.data(), 8); + { + PoolReadGuard pg2(¤tVecPdu2); + if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { + heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + } } } diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index fcea7e6d..e7c95218 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -208,7 +208,7 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; -class HeaterInfo : public StaticLocalDataSet<12> { +class HeaterInfo : public StaticLocalDataSet<3> { public: HeaterInfo(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HEATER_SET) {} HeaterInfo(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 28085105..0b495d53 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -361,13 +361,8 @@ ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState void HeaterHandler::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, submode); - SwitchState states[helper.heaters.size()]; - { - MutexGuard mg(heaterHealthAndStateMutex); - for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { - states[idx] = heaterVec[idx].switchState; - } - } + std::array states; + getAllSwitchStates(states); for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { if (states[idx] == ON) { EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_ON, 0); @@ -398,6 +393,19 @@ ModeTreeChildIF& HeaterHandler::getModeTreeChildIF() { return *this; } object_id_t HeaterHandler::getObjectId() const { return SystemObject::getObjectId(); } +ReturnValue_t HeaterHandler::getAllSwitchStates(std::array& statesBuf) { + { + MutexGuard mg(heaterHealthAndStateMutex); + if (mg.getLockResult() != returnvalue::OK) { + return returnvalue::FAILED; + } + for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { + statesBuf[idx] = heaterVec[idx].switchState; + } + } + return returnvalue::OK; +} + bool HeaterHandler::allSwitchesOff() { bool allSwitchesOrd = false; MutexGuard mg(heaterHealthAndStateMutex); diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index 9a776058..ffc38440 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -59,6 +59,7 @@ class HeaterHandler : public ExecutableObjectIF, static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); enum CmdSourceParam : uint8_t { INTERNAL = 0, EXTERNAL = 1 }; + enum SwitchState : uint8_t { ON = 1, OFF = 0 }; /** Device command IDs */ static const DeviceCommandId_t SWITCH_HEATER = 0x0; @@ -67,11 +68,11 @@ class HeaterHandler : public ExecutableObjectIF, PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch); ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + ReturnValue_t getAllSwitchStates(std::array& statesBuf); virtual ~HeaterHandler(); protected: - 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); diff --git a/tmtc b/tmtc index d1f96cb8..5f082cd9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d1f96cb83d287ea6f7714631fa944eb2c7fe17b8 +Subproject commit 5f082cd9fccdaa304f00d92c1f25cdd6a7d8ed0b