WIP: Update DHB command and reply map helpers #103

Closed
muellerr wants to merge 7 commits from mueller/update-cmd-reply-maps-refactoring into develop
3 changed files with 62 additions and 8 deletions
Showing only changes of commit c379f8671d - Show all commits

View File

@ -7,6 +7,8 @@
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"
#include "DeviceHandlerIF.h" #include "DeviceHandlerIF.h"
#include "DeviceHandlerThermalSet.h" #include "DeviceHandlerThermalSet.h"
#include "DhbCfgHelpers.h"
#include "fsfw/action/ActionHelper.h" #include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h" #include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/datapool/PoolVariableIF.h"
@ -488,9 +490,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @return - @c RETURN_OK when the command was successfully inserted, * @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInCommandMap(CmdCfg cfg);
bool useAlternativeReply = false,
DeviceCommandId_t alternativeReplyId = 0);
/** /**
* Enables a periodic reply for a given command. It sets to delay cycles to the specified * Enables a periodic reply for a given command. It sets to delay cycles to the specified

View File

@ -1 +0,0 @@
#include "DhbCfgHelpers.h"

View File

@ -1,12 +1,67 @@
#ifndef FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ #ifndef FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
#define FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ #define FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
struct CfgBase {}; /**
* @brief This is the base class for configuration related to both DHB commands, replies and their
* combination
*/
struct CfgBase {
public:
explicit CfgBase(DeviceCommandId_t cmdAndOrReplyId): cmdAndOrReplyId(cmdAndOrReplyId) {};
DeviceCommandId_t cmdAndOrReplyId;
};
struct CmdCfg {}; /**
* @brief Configuration class for commands
*/
struct CmdCfg {
public:
explicit CmdCfg(DeviceCommandId_t cmdId): baseCfg(cmdId) {};
struct ReplyCfg {}; CfgBase baseCfg;
//! This can be used if a command can trigger multiple replies
std::pair<bool, DeviceCommandId_t> alternativeReply = {false, DeviceHandlerIF::NO_COMMAND_ID};
};
struct CmdReplyCfg {}; /**
* @brief Configuration class for replies
*/
struct ReplyCfg {
public:
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles);
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles);
CfgBase baseCfg;
//! A data set can be mapped to a reply ID. This allows to omit the #getDataSetHandle
//! override in a user device handler as this pointer will be passed as long as the device
//! command ID is equal to the set ID.
LocalPoolDataSetBase* dataSet = nullptr;
//! For Command-Reply combinations:
//! The maximum number of cycles the handler should wait for a reply
//! to this command.
//!
//! Reply Only:
//! For periodic replies, this variable will be the number of delay cycles between the replies.
//! For the non-periodic variant, this variable is not used as there is no meaningful
//! definition for delay
uint16_t maxDelayCycles = 0;
//! First parameter: Specify whether reply is arriving periodically
//! Second parameter: Specify whether periodic reply should be enabled immediately
std::pair<bool, bool> periodicCfg = {false, false};
//! If a reply needs to be requested with a specific length, the length can be specified here
size_t replyLen = 0;
//! It is also possible to use a time based instead of a cycle based mechanism to specify
//! how long a reply takes. For non-periodic replies without a command, this variable is not used.
Countdown* countdown = nullptr;
};
/**
* @brief Configuration class for commands and replies
*/
struct CmdReplyCfg {
public:
CmdReplyCfg(CmdCfg cmdCfg, ReplyCfg replyCfg): cmdCfg(cmdCfg), replyCfg(replyCfg) {}
CmdCfg cmdCfg;
ReplyCfg replyCfg;
};
#endif /* FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ */ #endif /* FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ */