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(
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<DeviceHandlerIF::dh_heater_request_t>
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<DeviceHandlerIF::dh_heater_request_t>
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;
}
}

View File

@ -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.

View File

@ -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
*/

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_ */