From 74b2830d9b2c612bff9467f063617028cbf309a8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 18:55:53 +0100 Subject: [PATCH] using new device handler thermal set --- devicehandlers/DeviceHandlerBase.cpp | 56 ++++++++++++------------ devicehandlers/DeviceHandlerBase.h | 11 +++-- devicehandlers/DeviceHandlerIF.h | 9 ++++ devicehandlers/DeviceHandlerThermalSet.h | 44 +++++++++++++++++++ 4 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 devicehandlers/DeviceHandlerThermalSet.h diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 60929fcd..609ba315 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -58,9 +58,12 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) { } void DeviceHandlerBase::setThermalStateRequestPoolIds( - lp_id_t thermalStatePoolId, lp_id_t thermalRequestPoolId) { + lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId, + uint32_t thermalSetId) { this->deviceHeaterRequestPoolId = thermalStatePoolId; - this->deviceHeaterRequestPoolId = thermalRequestPoolId; + this->deviceHeaterRequestPoolId = heaterRequestPoolId; + thermalSet = new DeviceHandlerThermalSet(this, thermalSetId, + thermalStatePoolId, heaterRequestPoolId); } @@ -212,15 +215,14 @@ ReturnValue_t DeviceHandlerBase::initialize() { fillCommandAndReplyMap(); - if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) { + if(thermalSet != nullptr) { //Set temperature target state to NON_OP. - LocalPoolVar - heaterRequest(this, deviceHeaterRequestPoolId, nullptr, - pool_rwm_t::VAR_WRITE); - result = heaterRequest.read(); + ReturnValue_t result = thermalSet->read(); if(result == HasReturnvaluesIF::RETURN_OK) { - heaterRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - heaterRequest.commit(PoolVariableIF::VALID); + thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_WRITE); + thermalSet->heaterRequest.value = + ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; + thermalSet->commit(PoolVariableIF::VALID); } } @@ -513,18 +515,17 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { } Clock::getUptime(&timeoutStart); - if (mode == MODE_OFF) { - LocalPoolVar - heaterRequest(this, deviceHeaterRequestPoolId, - nullptr, PoolVariableIF::VAR_READ_WRITE); - ReturnValue_t result = heaterRequest.read(); + if (mode == MODE_OFF and thermalSet != nullptr) { + ReturnValue_t result = thermalSet->read(); if(result == HasReturnvaluesIF::RETURN_OK) { - if (heaterRequest.value != + thermalSet->heaterRequest.setReadWriteMode( + pool_rwm_t::VAR_READ_WRITE); + if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) { - heaterRequest.value = ThermalComponentIF:: + thermalSet->heaterRequest.value = ThermalComponentIF:: STATE_REQUEST_NON_OPERATIONAL; } - heaterRequest.commit(PoolVariableIF::VALID); + thermalSet->heaterRequest.commit(PoolVariableIF::VALID); } } @@ -989,17 +990,18 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, } if ((commandedMode == MODE_ON) && (mode == MODE_OFF) - && (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)) { - GlobDataSet mySet; - gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet, - PoolVariableIF::VAR_READ); - gp_uint8_t thermalRequest(deviceHeaterRequestPoolId, &mySet, - PoolVariableIF::VAR_READ); - mySet.read(); - if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { - if (!ThermalComponentIF::isOperational(thermalState)) { + && (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER) + and thermalSet != nullptr) { + ReturnValue_t result = thermalSet->read(); + if(result == HasReturnvaluesIF::RETURN_OK) { + thermalSet->thermalState.setReadWriteMode(pool_rwm_t::VAR_READ); + thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_READ); + if((thermalSet->heaterRequest.value != + ThermalComponentIF::STATE_REQUEST_IGNORE) and (not + ThermalComponentIF::isOperational( + thermalSet->thermalState.value))) { triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, - thermalState); + thermalSet->thermalState.value); return NON_OP_TEMPERATURE; } } diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index b41e7407..eb15f22a 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -4,6 +4,7 @@ #include "DeviceHandlerIF.h" #include "DeviceCommunicationIF.h" #include "DeviceHandlerFailureIsolation.h" +#include "DeviceHandlerThermalSet.h" #include "../objectmanager/SystemObject.h" #include "../tasks/ExecutableObjectIF.h" @@ -112,9 +113,11 @@ public: * @param thermalStatePoolId * @param thermalRequestPoolId */ - void setThermalStateRequestPoolIds( - lp_id_t thermalStatePoolId = localpool::INVALID_LPID - 1, - lp_id_t thermalRequestPoolId = localpool::INVALID_LPID - 2); + void setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId = + DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID, + lp_id_t thermalRequestPoolId = + DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID, + uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID); /** * @brief Helper function to ease device handler development. * This will instruct the transition to MODE_ON immediately @@ -718,6 +721,8 @@ protected: */ lp_id_t deviceHeaterRequestPoolId = localpool::INVALID_LPID; + DeviceHandlerThermalSet* thermalSet = nullptr; + /** * Optional Error code. Can be set in doStartUp(), doShutDown() and * doTransition() to signal cause for Transition failure. diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index f1ea8801..a86a2b3a 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -4,6 +4,7 @@ #include "DeviceHandlerMessage.h" #include "../action/HasActionsIF.h" +#include "../datapoollocal/locPoolDefinitions.h" #include "../events/Event.h" #include "../modes/HasModesIF.h" #include "../ipc/MessageQueueSenderIF.h" @@ -151,6 +152,14 @@ public: NOTHING //!< Do nothing. }; + static constexpr uint32_t DEFAULT_THERMAL_SET_ID = sid_t::INVALID_SID - 1; + + static constexpr lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = + localpool::INVALID_LPID - 2; + static constexpr lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = + localpool::INVALID_LPID - 1; + + /** * Default Destructor */ diff --git a/devicehandlers/DeviceHandlerThermalSet.h b/devicehandlers/DeviceHandlerThermalSet.h new file mode 100644 index 00000000..8e9f9c51 --- /dev/null +++ b/devicehandlers/DeviceHandlerThermalSet.h @@ -0,0 +1,44 @@ +#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ +#define FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ + +#include "DeviceHandlerIF.h" +#include "../datapoollocal/StaticLocalDataSet.h" +#include "../datapoollocal/LocalPoolVariable.h" + + +class DeviceHandlerThermalSet: public StaticLocalDataSet<2> { +public: + + DeviceHandlerThermalSet(HasLocalDataPoolIF* hkOwner, uint32_t setId = + DeviceHandlerIF::DEFAULT_THERMAL_SET_ID, + lp_id_t thermalStateId = + DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID, + lp_id_t heaterRequestId = + DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID): + DeviceHandlerThermalSet(hkOwner->getObjectId(), setId, + thermalStateId, heaterRequestId) {} + + DeviceHandlerThermalSet(object_id_t deviceHandler, uint32_t setId = + DeviceHandlerIF::DEFAULT_THERMAL_SET_ID, + lp_id_t thermalStateId = + DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID, + lp_id_t thermalStateRequestId = + DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID): + StaticLocalDataSet(sid_t(deviceHandler, setId)), + thermalStatePoolId(thermalStateId), + thermalStateRequestPoolId(thermalStateRequestId) {} + + const lp_id_t thermalStatePoolId; + const lp_id_t thermalStateRequestPoolId; + + lp_var_t thermalState = + lp_var_t( + thermalStatePoolId, sid.objectId, this); + lp_var_t heaterRequest = + lp_var_t( + thermalStateRequestPoolId, sid.objectId, this); +}; + + + +#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */