73 lines
2.6 KiB
C++
73 lines
2.6 KiB
C++
#ifndef FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
|
|
#define FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
|
|
|
|
/**
|
|
* @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;
|
|
};
|
|
|
|
/**
|
|
* @brief Configuration class for commands
|
|
*/
|
|
struct CmdCfg {
|
|
public:
|
|
explicit CmdCfg(DeviceCommandId_t cmdId) : baseCfg(cmdId){};
|
|
|
|
CfgBase baseCfg;
|
|
//! This can be used if a command can trigger multiple replies
|
|
std::pair<bool, DeviceCommandId_t> alternativeReply = {false, DeviceHandlerIF::NO_COMMAND_ID};
|
|
};
|
|
|
|
/**
|
|
* @brief Configuration class for replies
|
|
*/
|
|
struct ReplyCfg {
|
|
public:
|
|
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles)
|
|
: baseCfg(replyId), maxDelayCycles(maxDelayCycles){};
|
|
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles, LocalPoolDataSetBase* set)
|
|
: ReplyCfg(replyId, maxDelayCycles) {
|
|
dataSet = set;
|
|
};
|
|
|
|
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_ */
|