using new device handler thermal set

This commit is contained in:
Robin Müller 2020-12-01 18:55:53 +01:00
parent fff928a191
commit 74b2830d9b
4 changed files with 90 additions and 30 deletions

View File

@ -58,9 +58,12 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
} }
void DeviceHandlerBase::setThermalStateRequestPoolIds( 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 = thermalStatePoolId;
this->deviceHeaterRequestPoolId = thermalRequestPoolId; this->deviceHeaterRequestPoolId = heaterRequestPoolId;
thermalSet = new DeviceHandlerThermalSet(this, thermalSetId,
thermalStatePoolId, heaterRequestPoolId);
} }
@ -212,15 +215,14 @@ ReturnValue_t DeviceHandlerBase::initialize() {
fillCommandAndReplyMap(); fillCommandAndReplyMap();
if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) { if(thermalSet != nullptr) {
//Set temperature target state to NON_OP. //Set temperature target state to NON_OP.
LocalPoolVar<DeviceHandlerIF::dh_heater_request_t> ReturnValue_t result = thermalSet->read();
heaterRequest(this, deviceHeaterRequestPoolId, nullptr,
pool_rwm_t::VAR_WRITE);
result = heaterRequest.read();
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
heaterRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_WRITE);
heaterRequest.commit(PoolVariableIF::VALID); 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); Clock::getUptime(&timeoutStart);
if (mode == MODE_OFF) { if (mode == MODE_OFF and thermalSet != nullptr) {
LocalPoolVar<DeviceHandlerIF::dh_heater_request_t> ReturnValue_t result = thermalSet->read();
heaterRequest(this, deviceHeaterRequestPoolId,
nullptr, PoolVariableIF::VAR_READ_WRITE);
ReturnValue_t result = heaterRequest.read();
if(result == HasReturnvaluesIF::RETURN_OK) { 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) { ThermalComponentIF::STATE_REQUEST_IGNORE) {
heaterRequest.value = ThermalComponentIF:: thermalSet->heaterRequest.value = ThermalComponentIF::
STATE_REQUEST_NON_OPERATIONAL; 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) if ((commandedMode == MODE_ON) && (mode == MODE_OFF)
&& (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)) { && (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)
GlobDataSet mySet; and thermalSet != nullptr) {
gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet, ReturnValue_t result = thermalSet->read();
PoolVariableIF::VAR_READ); if(result == HasReturnvaluesIF::RETURN_OK) {
gp_uint8_t thermalRequest(deviceHeaterRequestPoolId, &mySet, thermalSet->thermalState.setReadWriteMode(pool_rwm_t::VAR_READ);
PoolVariableIF::VAR_READ); thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_READ);
mySet.read(); if((thermalSet->heaterRequest.value !=
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { ThermalComponentIF::STATE_REQUEST_IGNORE) and (not
if (!ThermalComponentIF::isOperational(thermalState)) { ThermalComponentIF::isOperational(
thermalSet->thermalState.value))) {
triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE,
thermalState); thermalSet->thermalState.value);
return NON_OP_TEMPERATURE; return NON_OP_TEMPERATURE;
} }
} }

View File

@ -4,6 +4,7 @@
#include "DeviceHandlerIF.h" #include "DeviceHandlerIF.h"
#include "DeviceCommunicationIF.h" #include "DeviceCommunicationIF.h"
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"
#include "DeviceHandlerThermalSet.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../tasks/ExecutableObjectIF.h" #include "../tasks/ExecutableObjectIF.h"
@ -112,9 +113,11 @@ public:
* @param thermalStatePoolId * @param thermalStatePoolId
* @param thermalRequestPoolId * @param thermalRequestPoolId
*/ */
void setThermalStateRequestPoolIds( void setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId =
lp_id_t thermalStatePoolId = localpool::INVALID_LPID - 1, DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
lp_id_t thermalRequestPoolId = localpool::INVALID_LPID - 2); 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. * @brief Helper function to ease device handler development.
* This will instruct the transition to MODE_ON immediately * This will instruct the transition to MODE_ON immediately
@ -718,6 +721,8 @@ protected:
*/ */
lp_id_t deviceHeaterRequestPoolId = localpool::INVALID_LPID; lp_id_t deviceHeaterRequestPoolId = localpool::INVALID_LPID;
DeviceHandlerThermalSet* thermalSet = nullptr;
/** /**
* Optional Error code. Can be set in doStartUp(), doShutDown() and * Optional Error code. Can be set in doStartUp(), doShutDown() and
* doTransition() to signal cause for Transition failure. * doTransition() to signal cause for Transition failure.

View File

@ -4,6 +4,7 @@
#include "DeviceHandlerMessage.h" #include "DeviceHandlerMessage.h"
#include "../action/HasActionsIF.h" #include "../action/HasActionsIF.h"
#include "../datapoollocal/locPoolDefinitions.h"
#include "../events/Event.h" #include "../events/Event.h"
#include "../modes/HasModesIF.h" #include "../modes/HasModesIF.h"
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
@ -151,6 +152,14 @@ public:
NOTHING //!< Do nothing. 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 * Default Destructor
*/ */

View File

@ -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<DeviceHandlerIF::dh_thermal_state_t> thermalState =
lp_var_t<DeviceHandlerIF::dh_thermal_state_t>(
thermalStatePoolId, sid.objectId, this);
lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
lp_var_t<DeviceHandlerIF::dh_heater_request_t>(
thermalStateRequestPoolId, sid.objectId, this);
};
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */