2020-09-26 14:58:53 +02:00
|
|
|
#ifndef FSFW_MODES_MODEMESSAGE_H_
|
|
|
|
#define FSFW_MODES_MODEMESSAGE_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-10-10 11:06:58 +02:00
|
|
|
#include "fsfw/ipc/CommandMessage.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
typedef uint32_t Mode_t;
|
|
|
|
typedef uint8_t Submode_t;
|
|
|
|
|
|
|
|
class ModeMessage {
|
2022-02-02 10:29:30 +01:00
|
|
|
public:
|
|
|
|
static const uint8_t MESSAGE_ID = messagetypes::MODE_COMMAND;
|
2022-10-10 11:06:58 +02:00
|
|
|
//!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY,
|
|
|
|
//! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies,
|
|
|
|
//! as this will break the subsystem mode machine!!
|
|
|
|
static const Command_t CMD_MODE_COMMAND = MAKE_COMMAND_ID(0x01);
|
|
|
|
//!> Command to set the specified Mode, regardless of external control flag, replies
|
|
|
|
//! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any
|
|
|
|
//! replies, as this will break the subsystem mode machine!!
|
|
|
|
static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID(0xF1);
|
|
|
|
//!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ
|
|
|
|
static const Command_t REPLY_MODE_REPLY = MAKE_COMMAND_ID(0x02);
|
|
|
|
//!> Unrequested info about the current mode (used for composites to
|
|
|
|
//! inform their container of a changed mode)
|
|
|
|
static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03);
|
|
|
|
//!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0
|
|
|
|
static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04);
|
|
|
|
//!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded
|
|
|
|
//! and a transition started but was aborted; the parameters contain
|
|
|
|
//! the mode that was reached
|
|
|
|
static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05);
|
|
|
|
//!> Command to read the current mode and reply with a REPLY_MODE_REPLY
|
|
|
|
static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06);
|
|
|
|
//!> Command to trigger an ModeInfo Event. This command does NOT have a reply.
|
|
|
|
static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07);
|
|
|
|
//!> Command to trigger an ModeInfo Event and to send this command to
|
|
|
|
//! every child. This command does NOT have a reply.
|
|
|
|
static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY = MAKE_COMMAND_ID(0x08);
|
|
|
|
|
|
|
|
ModeMessage() = delete;
|
2020-09-26 14:58:53 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
static Mode_t getMode(const CommandMessage* message);
|
|
|
|
static Submode_t getSubmode(const CommandMessage* message);
|
|
|
|
static ReturnValue_t getCantReachModeReason(const CommandMessage* message);
|
|
|
|
|
|
|
|
static void setModeMessage(CommandMessage* message, Command_t command, Mode_t mode,
|
|
|
|
Submode_t submode);
|
2022-10-10 11:06:58 +02:00
|
|
|
static void setModeAnnounceMessage(CommandMessage& message, bool recursive);
|
2022-02-02 10:29:30 +01:00
|
|
|
static void setCantReachMode(CommandMessage* message, ReturnValue_t reason);
|
|
|
|
static void clear(CommandMessage* message);
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-09-26 14:58:53 +02:00
|
|
|
#endif /* FSFW_MODES_MODEMESSAGE_H_ */
|