From c379f8671d49d4903cbb154ed524873c3a6b06e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 May 2022 18:10:10 +0200 Subject: [PATCH] added all new configuration classes --- src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 +- src/fsfw/devicehandlers/DhbCfgHelpers.cpp | 1 - src/fsfw/devicehandlers/DhbCfgHelpers.h | 63 +++++++++++++++++++-- 3 files changed, 62 insertions(+), 8 deletions(-) delete mode 100644 src/fsfw/devicehandlers/DhbCfgHelpers.cpp diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 34171067..3174fb0b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -7,6 +7,8 @@ #include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerIF.h" #include "DeviceHandlerThermalSet.h" +#include "DhbCfgHelpers.h" + #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" #include "fsfw/datapool/PoolVariableIF.h" @@ -488,9 +490,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ - ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, - bool useAlternativeReply = false, - DeviceCommandId_t alternativeReplyId = 0); + ReturnValue_t insertInCommandMap(CmdCfg cfg); /** * Enables a periodic reply for a given command. It sets to delay cycles to the specified diff --git a/src/fsfw/devicehandlers/DhbCfgHelpers.cpp b/src/fsfw/devicehandlers/DhbCfgHelpers.cpp deleted file mode 100644 index c8a60bb1..00000000 --- a/src/fsfw/devicehandlers/DhbCfgHelpers.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "DhbCfgHelpers.h" diff --git a/src/fsfw/devicehandlers/DhbCfgHelpers.h b/src/fsfw/devicehandlers/DhbCfgHelpers.h index b560f445..8301db16 100644 --- a/src/fsfw/devicehandlers/DhbCfgHelpers.h +++ b/src/fsfw/devicehandlers/DhbCfgHelpers.h @@ -1,12 +1,67 @@ #ifndef 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 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 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_ */