diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 91b40638..18f35fb2 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -103,6 +103,12 @@ ReturnValue_t ControllerBase::performOperation(uint8_t opCode) { void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {} +const ModeHelper * ControllerBase::getModeHelper() const { + return &modeHelper; +} + +void ControllerBase::modeChanged(Mode_t mode, Submode_t submode) { return; } + ReturnValue_t ControllerBase::setHealth(HealthState health) { switch (health) { case HEALTHY: diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 550659b8..f0b77078 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -3,6 +3,7 @@ #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthHelper.h" +#include "fsfw/introspection/ClasslessEnum.h" #include "fsfw/modes/HasModesIF.h" #include "fsfw/modes/ModeHelper.h" #include "fsfw/objectmanager/SystemObject.h" @@ -21,7 +22,9 @@ class ControllerBase : public HasModesIF, public SystemObject, public HasReturnvaluesIF { public: - static const Mode_t MODE_NORMAL = 2; + FSFW_CLASSLESS_ENUM(ControllerModes, Mode_t, + ((CONTROLLER_MODE_ON, MODE_ON, "On"))((CONTROLLER_MODE_OFF, MODE_OFF, + "Off"))((MODE_NORMAL, 2, "Normal"))) ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3); ~ControllerBase() override; @@ -40,6 +43,9 @@ class ControllerBase : public HasModesIF, void setTaskIF(PeriodicTaskIF *task) override; ReturnValue_t initializeAfterTaskCreation() override; + /** HasModeIF override */ + const ModeHelper *getModeHelper() const override; + protected: /** * Implemented by child class. Handle command messages which are not diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index c0bedec8..d6923bc2 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1325,11 +1325,9 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r } } -ActionHelper *DeviceHandlerBase::getActionHelper() { - return &actionHelper; -} +ActionHelper* DeviceHandlerBase::getActionHelper() { return &actionHelper; } -ReturnValue_t DeviceHandlerBase::executeAction(Action *action) { +ReturnValue_t DeviceHandlerBase::executeAction(Action* action) { ReturnValue_t result = acceptExternalDeviceCommands(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -1605,3 +1603,10 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } } } + +ModeHelper const* DeviceHandlerBase::getModeHelper() const { return &modeHelper; } + +ModeDefinitionHelper DeviceHandlerBase::getModeDefinitionHelper() { + return ModeDefinitionHelper::create(); +} + diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 7e255182..3b5b99c8 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -210,7 +210,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, Mode_t getTransitionSourceMode() const; Submode_t getTransitionSourceSubMode() const; - virtual void getMode(Mode_t *mode, Submode_t *submode); + void getMode(Mode_t *mode, Submode_t *submode) override; + ModeHelper const * getModeHelper() const override; + ModeDefinitionHelper getModeDefinitionHelper() override; HealthState getHealth(); ReturnValue_t setHealth(HealthState health); virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, diff --git a/src/fsfw/devicehandlers/DeviceHandlerIF.h b/src/fsfw/devicehandlers/DeviceHandlerIF.h index 1ea742f7..93b431ca 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerIF.h +++ b/src/fsfw/devicehandlers/DeviceHandlerIF.h @@ -4,6 +4,7 @@ #include "../action/HasActionsIF.h" #include "../datapoollocal/localPoolDefinitions.h" #include "../events/Event.h" +#include "../introspection/ClasslessEnum.h" #include "../ipc/MessageQueueSenderIF.h" #include "../modes/HasModesIF.h" #include "DeviceHandlerMessage.h" @@ -37,23 +38,30 @@ class DeviceHandlerIF { * The mode of the device itself is transparent to the user but related to the mode of the * handler. MODE_ON and MODE_OFF are included in hasModesIF.h */ + FSFW_CLASSLESS_ENUM( + DeviceHandlerMode, Mode_t, + //! The device is powered and ready to perform operations. In this mode, no + //! commands are sent by the device handler itself, but direct commands can be + //! commanded and will be executed/forwarded to the device + //! This is an alias of MODE_ON to have the FSFW_ENUM complete for introspection + ((DEVICEHANDLER_MODE_ON, HasModesIF::MODE_ON, "On")) + //! The device is powered off. The only command accepted in this + //! mode is a mode change to on. + //! This is an alias of MODE_OFF to have the FSFW_ENUM complete for introspection + ((DEVICEHANDLER_MODE_OFF, HasModesIF::MODE_OFF, "Off")) + //! The device is powered on and the device handler periodically sends + //! commands. The commands to be sent are selected by the handler + //! according to the submode. + ((MODE_NORMAL, 2, "Normal")) + //! The device is powered on and ready to perform operations. In this mode, + //! raw commands can be sent. The device handler will send all replies + //! received from the command back to the commanding object as raw TM + ((MODE_RAW, 3, "Raw")) + //! The device is shut down but the switch could not be turned off, so the + //! device still is powered. In this mode, only a mode change to @c MODE_OFF + //! can be commanded, which tries to switch off the device again. + ((MODE_ERROR_ON, 4, "Error"))) - // MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no - // commands are sent by the device handler itself, but direct commands van be commanded and will - // be interpreted MODE_OFF = 1, //!< The device is powered off. The only command accepted in this - // mode is a mode change to on. - //! The device is powered on and the device handler periodically sends - //! commands. The commands to be sent are selected by the handler - //! according to the submode. - static const Mode_t MODE_NORMAL = 2; - //! The device is powered on and ready to perform operations. In this mode, - //! raw commands can be sent. The device handler will send all replies - //! received from the command back to the commanding object. - static const Mode_t MODE_RAW = 3; - //! The device is shut down but the switch could not be turned off, so the - //! device still is powered. In this mode, only a mode change to @c MODE_OFF - //! can be commanded, which tries to switch off the device again. - static const Mode_t MODE_ERROR_ON = 4; //! This is a transitional state which can not be commanded. The device //! handler performs all commands to get the device in a state ready to //! perform commands. When this is completed, the mode changes to @c MODE_ON. diff --git a/src/fsfw/modes/HasModesIF.h b/src/fsfw/modes/HasModesIF.h index 69bfb834..79ee3c12 100644 --- a/src/fsfw/modes/HasModesIF.h +++ b/src/fsfw/modes/HasModesIF.h @@ -4,9 +4,10 @@ #include #include "../events/Event.h" +#include "../introspection/ClasslessEnum.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "ModeHelper.h" #include "ModeDefinitionHelper.h" +#include "ModeHelper.h" #include "ModeMessage.h" class HasModesIF { @@ -35,8 +36,9 @@ class HasModesIF { //! A mode command was rejected by the called object. Par1: called object id, Par2: return code. static const Event MODE_CMD_REJECTED = MAKE_EVENT(7, severity::LOW); +<<<<<<< HEAD //! The device is powered and ready to perform operations. In this mode, no commands are - //! sent by the device handler itself, but direct commands van be commanded and will be + //! sent by the device handler itself, but direct commands can be commanded and will be //! interpreted static constexpr Mode_t MODE_ON = 1; //! The device is powered off. The only command accepted in this mode is a mode change to on. @@ -45,12 +47,14 @@ class HasModesIF { static constexpr Mode_t MODE_INVALID = -1; static constexpr Mode_t MODE_UNDEFINED = -2; - //! To avoid checks against magic number "0". - static const Submode_t SUBMODE_NONE = 0; + FSFW_CLASSLESS_ENUM(DefaultSubmode, Submode_t, + ((SUBMODE_NONE, 0, + "Default"))) //!< To avoid checks against magic number "0". virtual ~HasModesIF() {} virtual MessageQueueId_t getCommandQueue() const = 0; - virtual ModeDefinitionHelper getModeDefinitionHelper()= 0; + virtual const ModeHelper * getModeHelper() const = 0; + virtual ModeDefinitionHelper getModeDefinitionHelper() = 0; virtual void getMode(Mode_t *mode, Submode_t *submode) = 0; protected: diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index aec96434..566c66a3 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -327,3 +327,7 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) { HasHealthIF::HealthState SubsystemBase::getHealth() { return healthHelper.getHealth(); } void SubsystemBase::modeChanged() {} + +const ModeHelper * SubsystemBase::getModeHelper() const { + return &modeHelper; +} \ No newline at end of file diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index bafb7fb1..1487eadd 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -41,7 +41,9 @@ class SubsystemBase : public SystemObject, uint16_t commandQueueDepth = 8); virtual ~SubsystemBase(); - virtual MessageQueueId_t getCommandQueue() const override; + MessageQueueId_t getCommandQueue() const override; + + const ModeHelper * getModeHelper() const override; /** * Function to register the child objects. @@ -56,13 +58,13 @@ class SubsystemBase : public SystemObject, */ ReturnValue_t registerChild(object_id_t objectId); - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t performOperation(uint8_t opCode) override; - virtual ReturnValue_t setHealth(HealthState health) override; + ReturnValue_t setHealth(HealthState health) override; - virtual HasHealthIF::HealthState getHealth() override; + HasHealthIF::HealthState getHealth() override; protected: struct ChildInfo {