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(
lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId,
uint32_t thermalSetId) {
this->deviceHeaterRequestPoolId = thermalStatePoolId;
this->deviceHeaterRequestPoolId = heaterRequestPoolId;
thermalSet = new DeviceHandlerThermalSet(this, thermalSetId,
thermalStatePoolId, heaterRequestPoolId);
}
@ -217,9 +215,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(thermalSet != nullptr) {
//Set temperature target state to NON_OP.
ReturnValue_t result = thermalSet->read();
result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.setReadWriteMode(pool_rwm_t::VAR_WRITE);
thermalSet->heaterRequest.value =
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
thermalSet->commit(PoolVariableIF::VALID);
@ -518,8 +515,6 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
if (mode == MODE_OFF and thermalSet != nullptr) {
ReturnValue_t result = thermalSet->read();
if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.setReadWriteMode(
pool_rwm_t::VAR_READ_WRITE);
if (thermalSet->heaterRequest.value !=
ThermalComponentIF::STATE_REQUEST_IGNORE) {
thermalSet->heaterRequest.value = ThermalComponentIF::
@ -990,12 +985,9 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode,
}
if ((commandedMode == MODE_ON) && (mode == MODE_OFF)
&& (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)
and thermalSet != nullptr) {
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(
@ -1014,32 +1006,15 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode,
Submode_t commandedSubmode) {
switch (commandedMode) {
case MODE_ON:
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);
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);
}
handleTransitionToOnMode(commandedMode, commandedSubmode);
break;
case MODE_OFF:
if (mode == MODE_OFF) {
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
setMode(_MODE_POWER_DOWN, commandedSubmode);
} 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);
transitionSourceMode = _MODE_POWER_DOWN;
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) {
*mode = this->mode;
*submode = this->submode;
@ -1401,13 +1403,10 @@ void DeviceHandlerBase::performOperationHook() {
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
LocalDataPool &localDataPoolMap,
LocalDataPoolManager& poolManager) {
if(deviceThermalStatePoolId != localpool::INVALID_LPID) {
localDataPoolMap.emplace(deviceThermalStatePoolId,
if(thermalSet != nullptr) {
localDataPoolMap.emplace(thermalSet->thermalStatePoolId,
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>);
}
if(deviceHeaterRequestPoolId != localpool::INVALID_LPID) {
localDataPoolMap.emplace(deviceHeaterRequestPoolId,
localDataPoolMap.emplace(thermalSet->heaterRequestPoolId,
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>);
}
return RETURN_OK;

View File

@ -107,9 +107,10 @@ public:
/**
* If the device handler is controlled by the FSFW thermal building blocks,
* this function should be called. The device handler will then take care
* of creating local pool entries for the device thermal state and device
* heating request. Custom local pool IDs can be assigned as well.
* this function should be called to initialize all required components.
* The device handler will then take care of creating local pool entries
* for the device thermal state and device heating request.
* Custom local pool IDs can be assigned as well.
* @param thermalStatePoolId
* @param thermalRequestPoolId
*/
@ -707,20 +708,6 @@ protected:
//! and to send replies.
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;
/**
@ -1223,6 +1210,9 @@ private:
void parseReply(const uint8_t* receivedData,
size_t receivedDataLen);
void handleTransitionToOnMode(Mode_t commandedMode,
Submode_t commandedSubmode);
};
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */

View File

@ -152,7 +152,7 @@ public:
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 =
localpool::INVALID_LPID - 2;

View File

@ -26,17 +26,17 @@ public:
DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID):
StaticLocalDataSet(sid_t(deviceHandler, setId)),
thermalStatePoolId(thermalStateId),
thermalStateRequestPoolId(thermalStateRequestId) {}
heaterRequestPoolId(thermalStateRequestId) {}
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>(
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);
heaterRequestPoolId, sid.objectId, this);
};