device handler uses local pools now

This commit is contained in:
Robin Müller 2020-12-08 15:59:30 +01:00
parent faedd40665
commit 5e2e18ac07
2 changed files with 193 additions and 124 deletions

View File

@ -3,8 +3,6 @@
#include "DeviceTmReportingWrapper.h" #include "DeviceTmReportingWrapper.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../datapoolglob/GlobalDataSet.h"
#include "../datapoolglob/GlobalPoolVariable.h"
#include "../objectmanager/ObjectManager.h" #include "../objectmanager/ObjectManager.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../thermal/ThermalComponentIF.h" #include "../thermal/ThermalComponentIF.h"
@ -13,9 +11,11 @@
#include "../ipc/MessageQueueMessage.h" #include "../ipc/MessageQueueMessage.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../subsystem/SubsystemBase.h" #include "../subsystem/SubsystemBase.h"
#include "../datapoollocal/LocalPoolVariable.h"
#include <iomanip> #include <iomanip>
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::defaultFdirParentId = 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( void DeviceHandlerBase::setThermalStateRequestPoolIds(
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId) { lp_id_t thermalStatePoolId, lp_id_t heaterRequestPoolId,
this->deviceThermalRequestPoolId = thermalStatePoolId; uint32_t thermalSetId) {
this->deviceThermalRequestPoolId = thermalRequestPoolId; thermalSet = new DeviceHandlerThermalSet(this, thermalSetId,
thermalStatePoolId, heaterRequestPoolId);
} }
@ -86,7 +87,6 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
decrementDeviceReplyMap(); decrementDeviceReplyMap();
fdirInstance->checkForFailures(); fdirInstance->checkForFailures();
hkSwitcher.performOperation(); hkSwitcher.performOperation();
hkManager.performHkOperation();
performOperationHook(); performOperationHook();
return RETURN_OK; return RETURN_OK;
} }
@ -111,6 +111,9 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
break; break;
case CommunicationAction::GET_READ: case CommunicationAction::GET_READ:
doGetRead(); doGetRead();
// This will be performed after datasets have been updated by the
// custom device implementation.
hkManager.performHkOperation();
break; break;
default: default:
break; break;
@ -208,16 +211,18 @@ ReturnValue_t DeviceHandlerBase::initialize() {
fillCommandAndReplyMap(); fillCommandAndReplyMap();
//Set temperature target state to NON_OP. if(thermalSet != nullptr) {
GlobDataSet mySet; //Set temperature target state to NON_OP.
gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, result = thermalSet->read();
PoolVariableIF::VAR_WRITE); if(result == HasReturnvaluesIF::RETURN_OK) {
mySet.read(); thermalSet->heaterRequest.value =
thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
mySet.commit(PoolVariableIF::VALID); thermalSet->commit(PoolVariableIF::VALID);
}
}
return RETURN_OK; return RETURN_OK;
} }
void DeviceHandlerBase::decrementDeviceReplyMap() { void DeviceHandlerBase::decrementDeviceReplyMap() {
@ -505,15 +510,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) {
GlobDataSet mySet; ReturnValue_t result = thermalSet->read();
gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, if(result == HasReturnvaluesIF::RETURN_OK) {
PoolVariableIF::VAR_READ_WRITE); if (thermalSet->heaterRequest.value !=
mySet.read(); ThermalComponentIF::STATE_REQUEST_IGNORE) {
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { thermalSet->heaterRequest.value = ThermalComponentIF::
thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; STATE_REQUEST_NON_OPERATIONAL;
}
thermalSet->heaterRequest.commit(PoolVariableIF::VALID);
} }
mySet.commit(PoolVariableIF::VALID);
} }
changeHK(mode, submode, true); changeHK(mode, submode, true);
} }
@ -976,17 +983,15 @@ 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)) {
GlobDataSet mySet; ReturnValue_t result = thermalSet->read();
gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet, if(result == HasReturnvaluesIF::RETURN_OK) {
PoolVariableIF::VAR_READ); if((thermalSet->heaterRequest.value !=
gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet, ThermalComponentIF::STATE_REQUEST_IGNORE) and (not
PoolVariableIF::VAR_READ); ThermalComponentIF::isOperational(
mySet.read(); thermalSet->thermalState.value))) {
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
if (!ThermalComponentIF::isOperational(thermalState)) {
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;
} }
} }
@ -999,32 +1004,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(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);
}
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;
@ -1050,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) { void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) {
*mode = this->mode; *mode = this->mode;
*submode = this->submode; *submode = this->submode;
@ -1222,10 +1237,12 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
} }
} }
//Try to cast to GlobDataSet and commit data. //Try to cast to GlobDataSet and commit data.
if (!neverInDataPool) { if (not neverInDataPool) {
GlobDataSet* dataSet = dynamic_cast<GlobDataSet*>(data); LocalPoolDataSetBase* dataSet =
if (dataSet != NULL) { dynamic_cast<LocalPoolDataSetBase*>(data);
dataSet->commit(PoolVariableIF::VALID); if (dataSet != nullptr) {
dataSet->setValidity(true, true);
dataSet->commit();
} }
} }
} }
@ -1262,7 +1279,8 @@ void DeviceHandlerBase::buildInternalCommand(void) {
if (result == BUSY) { if (result == BUSY) {
//so we can track misconfigurations //so we can track misconfigurations
sif::debug << std::hex << getObjectId() sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Busy" << std::dec << std::endl; << ": DHB::buildInternalCommand: Busy" << std::dec
<< std::endl;
result = NOTHING_TO_SEND; //no need to report this result = NOTHING_TO_SEND; //no need to report this
} }
} }
@ -1371,8 +1389,8 @@ bool DeviceHandlerBase::commandIsExecuting(DeviceCommandId_t commandId) {
void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) { void DeviceHandlerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {
} }
void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task_){ void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task){
executingTask = task_; executingTask = task;
} }
// Default implementations empty. // Default implementations empty.
@ -1385,6 +1403,12 @@ void DeviceHandlerBase::performOperationHook() {
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool( ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
LocalDataPool &localDataPoolMap, LocalDataPool &localDataPoolMap,
LocalDataPoolManager& poolManager) { 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; return RETURN_OK;
} }
@ -1429,3 +1453,9 @@ dur_millis_t DeviceHandlerBase::getPeriodicOperationFrequency() const {
return pstIntervalMs; return pstIntervalMs;
} }
DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const {
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
return cookieInfo.pendingCommand->first;
}
return DeviceHandlerIF::NO_COMMAND;
}

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"
@ -103,8 +104,21 @@ public:
size_t cmdQueueSize = 20); size_t cmdQueueSize = 20);
void setHkDestination(object_id_t hkDestination); 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. * @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
@ -694,19 +708,7 @@ protected:
//! and to send replies. //! and to send replies.
MessageQueueIF* commandQueue = nullptr; MessageQueueIF* commandQueue = nullptr;
/** DeviceHandlerThermalSet* thermalSet = 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;
/** /**
* Optional Error code. Can be set in doStartUp(), doShutDown() and * Optional Error code. Can be set in doStartUp(), doShutDown() and
@ -732,15 +734,27 @@ protected:
//! before setTaskIF was called. //! before setTaskIF was called.
PeriodicTaskIF* executingTask = nullptr; PeriodicTaskIF* executingTask = nullptr;
static object_id_t powerSwitcherId; //!< Object which switches power on and off. //!< Object which switches power on and off.
static object_id_t powerSwitcherId;
static object_id_t rawDataReceiverId; //!< Object which receives RAW data by default. //!< Object which receives RAW data by default.
static object_id_t rawDataReceiverId;
//!< Object which may be the root cause of an identified fault.
static object_id_t defaultFdirParentId;
/**
* Helper function to get pending command. This is useful for devices
* like SPI sensors to identify the last sent command.
* @return
*/
DeviceCommandId_t getPendingCommand() const;
static object_id_t defaultFdirParentId; //!< Object which may be the root cause of an identified fault.
/** /**
* Helper function to report a missed reply * Helper function to report a missed reply
* *
* Can be overwritten by children to act on missed replies or to fake reporting Id. * Can be overwritten by children to act on missed replies or to fake
* reporting Id.
* *
* @param id of the missed reply * @param id of the missed reply
*/ */
@ -847,15 +861,18 @@ protected:
/** /**
* Build the device command to send for raw mode. * Build the device command to send for raw mode.
* *
* This is only called in @c MODE_RAW. It is for the rare case that in raw mode packets * This is only called in @c MODE_RAW. It is for the rare case that in
* are to be sent by the handler itself. It is NOT needed for the raw commanding service. * raw mode packets are to be sent by the handler itself. It is NOT needed
* Its only current use is in the STR handler which gets its raw packets from a different * for the raw commanding service. Its only current use is in the STR
* source. * handler which gets its raw packets from a different source.
* Also it can be used for transitional commands, to get the device ready for @c MODE_RAW * Also it can be used for transitional commands, to get the device ready
* for @c MODE_RAW
* *
* As it is almost never used, there is a default implementation returning @c NOTHING_TO_SEND. * As it is almost never used, there is a default implementation
* returning @c NOTHING_TO_SEND.
* *
* #rawPacket and #rawPacketLen must be set by this method to the packet to be sent. * #rawPacket and #rawPacketLen must be set by this method to the packet
* to be sent.
* *
* @param[out] id the device command id built * @param[out] id the device command id built
* @return * @return
@ -868,7 +885,9 @@ protected:
* Returns the delay cycle count of a reply. * Returns the delay cycle count of a reply.
* A count != 0 indicates that the command is already executed. * A count != 0 indicates that the command is already executed.
* @param deviceCommand The command to look for * @param deviceCommand The command to look for
* @return The current delay count. If the command does not exist (should never happen) it returns 0. * @return
* The current delay count. If the command does not exist (should never
* happen) it returns 0.
*/ */
uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand); uint8_t getReplyDelayCycles(DeviceCommandId_t deviceCommand);
@ -878,20 +897,22 @@ protected:
* It gets space in the #IPCStore, copies data there, then sends a raw reply * It gets space in the #IPCStore, copies data there, then sends a raw reply
* containing the store address. * containing the store address.
* *
* This method is virtual, as the STR has a different channel to send raw replies * This method is virtual, as the STR has a different channel to send
* and overwrites it accordingly. * raw replies and overwrites it accordingly.
* *
* @param data data to send * @param data data to send
* @param len length of @c data * @param len length of @c data
* @param sendTo the messageQueueId of the one to send to * @param sendTo the messageQueueId of the one to send to
* @param isCommand marks the raw data as a command, the message then will be of type raw_command * @param isCommand marks the raw data as a command, the message then
* will be of type raw_command
*/ */
virtual void replyRawData(const uint8_t *data, size_t len, virtual void replyRawData(const uint8_t *data, size_t len,
MessageQueueId_t sendTo, bool isCommand = false); MessageQueueId_t sendTo, bool isCommand = false);
/** /**
* Calls replyRawData() with #defaultRawReceiver, but checks if wiretapping is active and if so, * Calls replyRawData() with #defaultRawReceiver, but checks if wiretapping
* does not send the Data as the wiretapping will have sent it already * is active and if so, does not send the data as the wiretapping will have
* sent it already
*/ */
void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len); void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len);
@ -903,17 +924,19 @@ protected:
/** /**
* Enable the reply checking for a command * Enable the reply checking for a command
* *
* Is only called, if the command was sent (ie the getWriteReply was successful). * Is only called, if the command was sent (i.e. the getWriteReply was
* Must ensure that all replies are activated and correctly linked to the command that initiated it. * successful). Must ensure that all replies are activated and correctly
* The default implementation looks for a reply with the same id as the command id in the replyMap or * linked to the command that initiated it.
* uses the alternativeReplyId if flagged so. * The default implementation looks for a reply with the same id as the
* When found, copies maxDelayCycles to delayCycles in the reply information and sets the command to * command id in the replyMap or uses the alternativeReplyId if flagged so.
* expect one reply. * When found, copies maxDelayCycles to delayCycles in the reply information
* and sets the command to expect one reply.
* *
* Can be overwritten by the child, if a command activates multiple replies * Can be overwritten by the child, if a command activates multiple replies
* or replyId differs from commandId. * or replyId differs from commandId.
* Notes for child implementations: * Notes for child implementations:
* - If the command was not found in the reply map, NO_REPLY_EXPECTED MUST be returned. * - If the command was not found in the reply map,
* NO_REPLY_EXPECTED MUST be returned.
* - A failure code may be returned if something went fundamentally wrong. * - A failure code may be returned if something went fundamentally wrong.
* *
* @param deviceCommand * @param deviceCommand
@ -929,17 +952,20 @@ protected:
* get the state of the PCDU switches in the datapool * get the state of the PCDU switches in the datapool
* *
* @return * @return
* - @c PowerSwitchIF::SWITCH_ON if all switches specified by #switches are on * - @c PowerSwitchIF::SWITCH_ON if all switches specified
* - @c PowerSwitchIF::SWITCH_OFF one of the switches specified by #switches are off * by #switches are on
* - @c PowerSwitchIF::RETURN_FAILED if an error occured * - @c PowerSwitchIF::SWITCH_OFF one of the switches specified by
* #switches are off
* - @c PowerSwitchIF::RETURN_FAILED if an error occured
*/ */
ReturnValue_t getStateOfSwitches(void); ReturnValue_t getStateOfSwitches(void);
/** /**
* set all datapool variables that are update periodically in normal mode invalid * @brief Set all datapool variables that are update periodically in
* * normal mode invalid
* Child classes should provide an implementation which sets all those variables invalid * @details TODO: Use local pools
* which are set periodically during any normal mode. * Child classes should provide an implementation which sets all those
* variables invalid which are set periodically during any normal mode.
*/ */
virtual void setNormalDatapoolEntriesInvalid() = 0; virtual void setNormalDatapoolEntriesInvalid() = 0;
@ -949,11 +975,12 @@ protected:
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable); virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
/** /**
* Children can overwrite this function to suppress checking of the command Queue * Children can overwrite this function to suppress checking of the
* command Queue
* *
* This can be used when the child does not want to receive a command in a certain * This can be used when the child does not want to receive a command in
* situation. Care must be taken that checking is not permanentely disabled as this * a certain situation. Care must be taken that checking is not
* would render the handler unusable. * permanentely disabled as this would render the handler unusable.
* *
* @return whether checking the queue should NOT be done * @return whether checking the queue should NOT be done
*/ */
@ -992,17 +1019,20 @@ protected:
virtual void forwardEvent(Event event, uint32_t parameter1 = 0, virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
uint32_t parameter2 = 0) const; uint32_t parameter2 = 0) const;
/** /**
* Checks state of switches in conjunction with mode and triggers an event if they don't fit. * Checks state of switches in conjunction with mode and triggers an event
* if they don't fit.
*/ */
virtual void checkSwitchState(); virtual void checkSwitchState();
/** /**
* Reserved for the rare case where a device needs to perform additional operation cyclically in OFF mode. * Reserved for the rare case where a device needs to perform additional
* operation cyclically in OFF mode.
*/ */
virtual void doOffActivity(); virtual void doOffActivity();
/** /**
* Reserved for the rare case where a device needs to perform additional operation cyclically in ON mode. * Reserved for the rare case where a device needs to perform additional
* operation cyclically in ON mode.
*/ */
virtual void doOnActivity(); virtual void doOnActivity();
@ -1043,9 +1073,10 @@ private:
/** /**
* Information about a cookie. * Information about a cookie.
* *
* This is stored in a map for each cookie, to not only track the state, but also information * This is stored in a map for each cookie, to not only track the state,
* about the sent command. Tracking this information is needed as * but also information about the sent command. Tracking this information
* the state of a commandId (waiting for reply) is done when a RMAP write reply is received. * is needed as the state of a commandId (waiting for reply) is done when a
* write reply is received.
*/ */
struct CookieInfo { struct CookieInfo {
CookieState_t state; CookieState_t state;
@ -1102,10 +1133,14 @@ private:
/** /**
* Handle the device handler mode. * Handle the device handler mode.
* *
* - checks whether commands are valid for the current mode, rejects them accordingly * - checks whether commands are valid for the current mode, rejects
* - checks whether commanded mode transitions are required and calls handleCommandedModeTransition() * them accordingly
* - does the necessary action for the current mode or calls doChildStateMachine in modes @c MODE_TO_ON and @c MODE_TO_OFF * - checks whether commanded mode transitions are required and calls
* - actions that happen in transitions (eg setting a timeout) are handled in setMode() * handleCommandedModeTransition()
* - does the necessary action for the current mode or calls
* doChildStateMachine in modes @c MODE_TO_ON and @c MODE_TO_OFF
* - actions that happen in transitions (e.g. setting a timeout) are
* handled in setMode()
*/ */
void doStateMachine(void); void doStateMachine(void);
@ -1115,16 +1150,17 @@ private:
/** /**
* Decrement the counter for the timout of replies. * Decrement the counter for the timout of replies.
* *
* This is called at the beginning of each cycle. It checks whether a reply has timed out (that means a reply was expected * This is called at the beginning of each cycle. It checks whether a
* but not received). * reply has timed out (that means a reply was expected but not received).
*/ */
void decrementDeviceReplyMap(void); void decrementDeviceReplyMap(void);
/** /**
* Convenience function to handle a reply. * Convenience function to handle a reply.
* *
* Called after scanForReply() has found a packet. Checks if the found id is in the #deviceCommandMap, if so, * Called after scanForReply() has found a packet. Checks if the found ID
* calls interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) for further action. * is in the #deviceCommandMap, if so, calls
* #interpretDeviceReply for further action.
* *
* It also resets the timeout counter for the command id. * It also resets the timeout counter for the command id.
* *
@ -1184,7 +1220,7 @@ private:
* @param[out] len * @param[out] len
* @return * @return
* - @c RETURN_OK @c data is valid * - @c RETURN_OK @c data is valid
* - @c RETURN_FAILED IPCStore is NULL * - @c RETURN_FAILED IPCStore is nullptr
* - the return value from the IPCStore if it was not @c RETURN_OK * - the return value from the IPCStore if it was not @c RETURN_OK
*/ */
ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data,
@ -1208,6 +1244,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_ */