Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/KSat/fsfw into mueller/master
This commit is contained in:
@ -3,8 +3,6 @@
|
||||
#include "DeviceTmReportingWrapper.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/GlobalPoolVariable.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../thermal/ThermalComponentIF.h"
|
||||
@ -13,9 +11,11 @@
|
||||
#include "../ipc/MessageQueueMessage.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../datapoollocal/LocalPoolVariable.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
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,9 +56,10 @@ void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::setThermalStateRequestPoolIds(
|
||||
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId) {
|
||||
this->deviceThermalRequestPoolId = thermalStatePoolId;
|
||||
this->deviceThermalRequestPoolId = thermalRequestPoolId;
|
||||
lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId,
|
||||
uint32_t thermalSetId) {
|
||||
thermalSet = new DeviceHandlerThermalSet(this, thermalSetId,
|
||||
thermalStatePoolId, heaterRequestPoolId);
|
||||
}
|
||||
|
||||
|
||||
@ -210,16 +211,18 @@ 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);
|
||||
if(thermalSet != nullptr) {
|
||||
//Set temperature target state to NON_OP.
|
||||
result = thermalSet->read();
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
thermalSet->heaterRequest.value =
|
||||
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
|
||||
thermalSet->commit(PoolVariableIF::VALID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::decrementDeviceReplyMap() {
|
||||
@ -507,15 +510,17 @@ 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;
|
||||
if (mode == MODE_OFF and thermalSet != nullptr) {
|
||||
ReturnValue_t result = thermalSet->read();
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
if (thermalSet->heaterRequest.value !=
|
||||
ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
||||
thermalSet->heaterRequest.value = ThermalComponentIF::
|
||||
STATE_REQUEST_NON_OPERATIONAL;
|
||||
}
|
||||
thermalSet->heaterRequest.commit(PoolVariableIF::VALID);
|
||||
}
|
||||
mySet.commit(PoolVariableIF::VALID);
|
||||
|
||||
}
|
||||
changeHK(mode, submode, true);
|
||||
}
|
||||
@ -978,17 +983,15 @@ 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(deviceThermalRequestPoolId, &mySet,
|
||||
PoolVariableIF::VAR_READ);
|
||||
mySet.read();
|
||||
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
||||
if (!ThermalComponentIF::isOperational(thermalState)) {
|
||||
and (thermalSet != nullptr)) {
|
||||
ReturnValue_t result = thermalSet->read();
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1001,32 +1004,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(deviceThermalRequestPoolId,
|
||||
&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;
|
||||
@ -1052,6 +1038,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;
|
||||
@ -1224,10 +1237,12 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
|
||||
}
|
||||
}
|
||||
//Try to cast to GlobDataSet and commit data.
|
||||
if (!neverInDataPool) {
|
||||
GlobDataSet* dataSet = dynamic_cast<GlobDataSet*>(data);
|
||||
if (dataSet != NULL) {
|
||||
dataSet->commit(PoolVariableIF::VALID);
|
||||
if (not neverInDataPool) {
|
||||
LocalPoolDataSetBase* dataSet =
|
||||
dynamic_cast<LocalPoolDataSetBase*>(data);
|
||||
if (dataSet != nullptr) {
|
||||
dataSet->setValidity(true, true);
|
||||
dataSet->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1374,8 +1389,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.
|
||||
@ -1388,6 +1403,12 @@ void DeviceHandlerBase::performOperationHook() {
|
||||
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
|
||||
LocalDataPool &localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
if(thermalSet != nullptr) {
|
||||
localDataPoolMap.emplace(thermalSet->thermalStatePoolId,
|
||||
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>);
|
||||
localDataPoolMap.emplace(thermalSet->heaterRequestPoolId,
|
||||
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>);
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "DeviceHandlerIF.h"
|
||||
#include "DeviceCommunicationIF.h"
|
||||
#include "DeviceHandlerFailureIsolation.h"
|
||||
#include "DeviceHandlerThermalSet.h"
|
||||
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
@ -103,8 +104,21 @@ public:
|
||||
size_t cmdQueueSize = 20);
|
||||
|
||||
void setHkDestination(object_id_t hkDestination);
|
||||
void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId,
|
||||
uint32_t thermalRequestPoolId);
|
||||
|
||||
/**
|
||||
* If the device handler is controlled by the FSFW thermal building blocks,
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
@ -220,7 +234,7 @@ protected:
|
||||
* - If the device does not change the mode, the mode will be changed to
|
||||
* _MODE_POWER_DOWN, when the timeout (from getTransitionDelay())
|
||||
* has passed.
|
||||
*
|
||||
* 0xffffffff
|
||||
* #transitionFailure can be set to a failure code indicating the reason
|
||||
* for a failed transition
|
||||
*/
|
||||
@ -694,19 +708,7 @@ 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
|
||||
*/
|
||||
uint32_t deviceThermalStatePoolId = PoolVariableIF::NO_PARAMETER;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
DeviceHandlerThermalSet* thermalSet = nullptr;
|
||||
|
||||
/**
|
||||
* Optional Error code. Can be set in doStartUp(), doShutDown() and
|
||||
@ -1229,6 +1231,9 @@ private:
|
||||
|
||||
void parseReply(const uint8_t* receivedData,
|
||||
size_t receivedDataLen);
|
||||
|
||||
void handleTransitionToOnMode(Mode_t commandedMode,
|
||||
Submode_t commandedSubmode);
|
||||
};
|
||||
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */
|
||||
|
@ -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"
|
||||
@ -21,11 +22,14 @@ using DeviceCommandId_t = uint32_t;
|
||||
*/
|
||||
class DeviceHandlerIF {
|
||||
public:
|
||||
static const DeviceCommandId_t NO_COMMAND = 0xffffffff;
|
||||
static const DeviceCommandId_t NO_COMMAND = -1;
|
||||
|
||||
static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
|
||||
static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
|
||||
|
||||
using dh_heater_request_t = uint8_t;
|
||||
using dh_thermal_state_t = int8_t;
|
||||
|
||||
/**
|
||||
* @brief This is the mode the <strong>device handler</strong> is in.
|
||||
*
|
||||
@ -148,6 +152,14 @@ public:
|
||||
NOTHING //!< Do nothing.
|
||||
};
|
||||
|
||||
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;
|
||||
static constexpr lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID =
|
||||
localpool::INVALID_LPID - 1;
|
||||
|
||||
|
||||
/**
|
||||
* Default Destructor
|
||||
*/
|
||||
|
44
devicehandlers/DeviceHandlerThermalSet.h
Normal file
44
devicehandlers/DeviceHandlerThermalSet.h
Normal 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),
|
||||
heaterRequestPoolId(thermalStateRequestId) {}
|
||||
|
||||
const lp_id_t thermalStatePoolId;
|
||||
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>(
|
||||
heaterRequestPoolId, sid.objectId, this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */
|
Reference in New Issue
Block a user