device handler changes complete

This commit is contained in:
Robin Müller 2020-12-01 19:12:40 +01:00
parent 74b2830d9b
commit e3de5ce777
4 changed files with 46 additions and 57 deletions

View File

@ -60,8 +60,6 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
void DeviceHandlerBase::setThermalStateRequestPoolIds( void DeviceHandlerBase::setThermalStateRequestPoolIds(
lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId, lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId,
uint32_t thermalSetId) { uint32_t thermalSetId) {
this->deviceHeaterRequestPoolId = thermalStatePoolId;
this->deviceHeaterRequestPoolId = heaterRequestPoolId;
thermalSet = new DeviceHandlerThermalSet(this, thermalSetId, thermalSet = new DeviceHandlerThermalSet(this, thermalSetId,
thermalStatePoolId, heaterRequestPoolId); thermalStatePoolId, heaterRequestPoolId);
} }
@ -217,9 +215,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(thermalSet != nullptr) { if(thermalSet != nullptr) {
//Set temperature target state to NON_OP. //Set temperature target state to NON_OP.
ReturnValue_t result = thermalSet->read(); result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_WRITE);
thermalSet->heaterRequest.value = thermalSet->heaterRequest.value =
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
thermalSet->commit(PoolVariableIF::VALID); thermalSet->commit(PoolVariableIF::VALID);
@ -518,8 +515,6 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
if (mode == MODE_OFF and thermalSet != nullptr) { if (mode == MODE_OFF and thermalSet != nullptr) {
ReturnValue_t result = thermalSet->read(); ReturnValue_t result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.setReadWriteMode(
pool_rwm_t::VAR_READ_WRITE);
if (thermalSet->heaterRequest.value != if (thermalSet->heaterRequest.value !=
ThermalComponentIF::STATE_REQUEST_IGNORE) { ThermalComponentIF::STATE_REQUEST_IGNORE) {
thermalSet->heaterRequest.value = ThermalComponentIF:: thermalSet->heaterRequest.value = ThermalComponentIF::
@ -990,12 +985,9 @@ 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) and (thermalSet != nullptr)) {
and thermalSet != nullptr) {
ReturnValue_t result = thermalSet->read(); ReturnValue_t result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) { 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 != if((thermalSet->heaterRequest.value !=
ThermalComponentIF::STATE_REQUEST_IGNORE) and (not ThermalComponentIF::STATE_REQUEST_IGNORE) and (not
ThermalComponentIF::isOperational( ThermalComponentIF::isOperational(
@ -1014,32 +1006,15 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode,
Submode_t commandedSubmode) { Submode_t commandedSubmode) {
switch (commandedMode) { switch (commandedMode) {
case MODE_ON: case MODE_ON:
if (mode == MODE_OFF) { handleTransitionToOnMode(commandedMode, commandedSubmode);
transitionSourceMode = _MODE_POWER_DOWN;
transitionSourceSubMode = SUBMODE_NONE;
setMode(_MODE_POWER_ON, commandedSubmode);
//already set the delay for the child transition so we don't need to call it twice
childTransitionDelay = getTransitionDelayMs(_MODE_START_UP,
MODE_ON);
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
GlobDataSet mySet;
gp_int8_t thermalRequest(deviceHeaterRequestPoolId,
&mySet, PoolVariableIF::VAR_READ_WRITE);
mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
thermalRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL;
mySet.commit(PoolVariableIF::VALID);
}
} else {
setTransition(MODE_ON, commandedSubmode);
}
break; break;
case MODE_OFF: case MODE_OFF:
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
setMode(_MODE_POWER_DOWN, commandedSubmode); setMode(_MODE_POWER_DOWN, commandedSubmode);
} else { } else {
//already set the delay for the child transition so we don't need to call it twice // already set the delay for the child transition
// so we don't need to call it twice
childTransitionDelay = getTransitionDelayMs(mode, _MODE_POWER_DOWN); childTransitionDelay = getTransitionDelayMs(mode, _MODE_POWER_DOWN);
transitionSourceMode = _MODE_POWER_DOWN; transitionSourceMode = _MODE_POWER_DOWN;
transitionSourceSubMode = commandedSubmode; transitionSourceSubMode = commandedSubmode;
@ -1065,6 +1040,33 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode,
} }
} }
void DeviceHandlerBase::handleTransitionToOnMode(Mode_t commandedMode,
Submode_t commandedSubmode) {
if (mode == MODE_OFF) {
transitionSourceMode = _MODE_POWER_DOWN;
transitionSourceSubMode = SUBMODE_NONE;
setMode(_MODE_POWER_ON, commandedSubmode);
// already set the delay for the child transition so we don't
// need to call it twice
childTransitionDelay = getTransitionDelayMs(_MODE_START_UP,
MODE_ON);
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
if(thermalSet != nullptr) {
ReturnValue_t result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) {
if(thermalSet->heaterRequest !=
ThermalComponentIF::STATE_REQUEST_IGNORE) {
thermalSet->heaterRequest =
ThermalComponentIF::STATE_REQUEST_OPERATIONAL;
thermalSet->commit();
}
}
}
} else {
setTransition(MODE_ON, commandedSubmode);
}
}
void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) { void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) {
*mode = this->mode; *mode = this->mode;
*submode = this->submode; *submode = this->submode;
@ -1401,13 +1403,10 @@ void DeviceHandlerBase::performOperationHook() {
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool( ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
LocalDataPool &localDataPoolMap, LocalDataPool &localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
if(deviceThermalStatePoolId != localpool::INVALID_LPID) { if(thermalSet != nullptr) {
localDataPoolMap.emplace(deviceThermalStatePoolId, localDataPoolMap.emplace(thermalSet->thermalStatePoolId,
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>); new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>);
} localDataPoolMap.emplace(thermalSet->heaterRequestPoolId,
if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) {
localDataPoolMap.emplace(deviceHeaterRequestPoolId,
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>); new PoolEntry<DeviceHandlerIF::dh_heater_request_t>);
} }
return RETURN_OK; return RETURN_OK;

View File

@ -107,9 +107,10 @@ public:
/** /**
* If the device handler is controlled by the FSFW thermal building blocks, * If the device handler is controlled by the FSFW thermal building blocks,
* this function should be called. The device handler will then take care * this function should be called to initialize all required components.
* of creating local pool entries for the device thermal state and device * The device handler will then take care of creating local pool entries
* heating request. Custom local pool IDs can be assigned as well. * for the device thermal state and device heating request.
* Custom local pool IDs can be assigned as well.
* @param thermalStatePoolId * @param thermalStatePoolId
* @param thermalRequestPoolId * @param thermalRequestPoolId
*/ */
@ -707,20 +708,6 @@ protected:
//! and to send replies. //! and to send replies.
MessageQueueIF* commandQueue = nullptr; MessageQueueIF* commandQueue = nullptr;
/**
* this is the datapool variable with the thermal state of the device
*
* can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking
*/
lp_id_t deviceThermalStatePoolId = localpool::INVALID_LPID;
/**
* this is the datapool variable with the thermal request of the device
*
* can be set to PoolVariableIF::NO_PARAMETER to deactivate thermal checking
*/
lp_id_t deviceHeaterRequestPoolId = localpool::INVALID_LPID;
DeviceHandlerThermalSet* thermalSet = nullptr; DeviceHandlerThermalSet* thermalSet = nullptr;
/** /**
@ -1223,6 +1210,9 @@ private:
void parseReply(const uint8_t* receivedData, void parseReply(const uint8_t* receivedData,
size_t receivedDataLen); size_t receivedDataLen);
void handleTransitionToOnMode(Mode_t commandedMode,
Submode_t commandedSubmode);
}; };
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */

View File

@ -152,7 +152,7 @@ public:
NOTHING //!< Do nothing. NOTHING //!< Do nothing.
}; };
static constexpr uint32_t DEFAULT_THERMAL_SET_ID = sid_t::INVALID_SID - 1; static constexpr uint32_t DEFAULT_THERMAL_SET_ID = sid_t::INVALID_SET_ID - 1;
static constexpr lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = static constexpr lp_id_t DEFAULT_THERMAL_STATE_POOL_ID =
localpool::INVALID_LPID - 2; localpool::INVALID_LPID - 2;

View File

@ -26,17 +26,17 @@ public:
DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID): DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID):
StaticLocalDataSet(sid_t(deviceHandler, setId)), StaticLocalDataSet(sid_t(deviceHandler, setId)),
thermalStatePoolId(thermalStateId), thermalStatePoolId(thermalStateId),
thermalStateRequestPoolId(thermalStateRequestId) {} heaterRequestPoolId(thermalStateRequestId) {}
const lp_id_t thermalStatePoolId; const lp_id_t thermalStatePoolId;
const lp_id_t thermalStateRequestPoolId; const lp_id_t heaterRequestPoolId;
lp_var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState = lp_var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState =
lp_var_t<DeviceHandlerIF::dh_thermal_state_t>( lp_var_t<DeviceHandlerIF::dh_thermal_state_t>(
thermalStatePoolId, sid.objectId, this); thermalStatePoolId, sid.objectId, this);
lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest = lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
lp_var_t<DeviceHandlerIF::dh_heater_request_t>( lp_var_t<DeviceHandlerIF::dh_heater_request_t>(
thermalStateRequestPoolId, sid.objectId, this); heaterRequestPoolId, sid.objectId, this);
}; };