From 0116bb86635d9480f74b87e83a267d66e6f904e0 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 18:15:09 +0100 Subject: [PATCH] replacing global pool with local pool DHB --- devicehandlers/DeviceHandlerBase.cpp | 39 ++++++++++++++++------------ devicehandlers/DeviceHandlerBase.h | 8 +++--- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index ccd5bebb..969c4688 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,6 +16,7 @@ #include +#include "../datapoollocal/LocalPoolVariable.h" object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT; @@ -56,7 +57,7 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) { } void DeviceHandlerBase::setThermalStateRequestPoolIds( - uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId) { + gp_id_t thermalStatePoolId, gp_id_t thermalRequestPoolId) { this->deviceThermalRequestPoolId = thermalStatePoolId; this->deviceThermalRequestPoolId = thermalRequestPoolId; } @@ -211,15 +212,15 @@ ReturnValue_t DeviceHandlerBase::initialize() { fillCommandAndReplyMap(); //Set temperature target state to NON_OP. - GlobDataSet mySet; - gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, - PoolVariableIF::VAR_WRITE); - mySet.read(); - thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - mySet.commit(PoolVariableIF::VALID); + LocalPoolVar thermalRequest(deviceThermalRequestPoolId, nullptr, + pool_rwm_t::VAR_WRITE); + ReturnValue_t result = thermalRequest.read(); + if(result == HasReturnvaluesIF::RETURN_OK) { + thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; + thermalRequest.commit(PoolVariableIF::VALID); + } return RETURN_OK; - } void DeviceHandlerBase::decrementDeviceReplyMap() { @@ -508,14 +509,18 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { Clock::getUptime(&timeoutStart); if (mode == MODE_OFF) { - GlobDataSet mySet; - gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, - PoolVariableIF::VAR_READ_WRITE); - mySet.read(); - if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { - thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; + LocalPoolVar heaterRequest(deviceThermalRequestPoolId, + nullptr, PoolVariableIF::VAR_READ_WRITE); + ReturnValue_t result = heaterRequest.read(); + if(heaterRequest == HasReturnvaluesIF::RETURN_OK) { + if (heaterRequest.value != + ThermalComponentIF::STATE_REQUEST_IGNORE) { + heaterRequest.value = ThermalComponentIF:: + STATE_REQUEST_NON_OPERATIONAL; + } + heaterRequest.commit(PoolVariableIF::VALID); } - mySet.commit(PoolVariableIF::VALID); + } changeHK(mode, submode, true); } @@ -1374,8 +1379,8 @@ bool DeviceHandlerBase::commandIsExecuting(DeviceCommandId_t commandId) { void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) { } -void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_){ - executingTask = task_; +void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task){ + executingTask = task; } // Default implementations empty. diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 627a6423..f5d6ec2b 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -103,8 +103,8 @@ public: size_t cmdQueueSize = 20); void setHkDestination(object_id_t hkDestination); - void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId, - uint32_t thermalRequestPoolId); + void setThermalStateRequestPoolIds(gp_id_t thermalStatePoolId, + gp_id_t thermalRequestPoolId); /** * @brief Helper function to ease device handler development. * This will instruct the transition to MODE_ON immediately @@ -699,14 +699,14 @@ protected: * * can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking */ - uint32_t deviceThermalStatePoolId = PoolVariableIF::NO_PARAMETER; + gp_id_t deviceThermalStatePoolId; /** * this is the datapool variable with the thermal request of the device * * can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking */ - uint32_t deviceThermalRequestPoolId = PoolVariableIF::NO_PARAMETER; + gp_id_t deviceThermalRequestPoolId; /** * Optional Error code. Can be set in doStartUp(), doShutDown() and