some more mode introspection

This commit is contained in:
Ulrich Mohr 2022-08-26 09:56:49 +02:00
parent 3f8f17a66e
commit bc593c938d
4 changed files with 42 additions and 24 deletions

View File

@ -1263,11 +1263,9 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r
} }
} }
ActionHelper *DeviceHandlerBase::getActionHelper() { ActionHelper* DeviceHandlerBase::getActionHelper() { return &actionHelper; }
return &actionHelper;
}
ReturnValue_t DeviceHandlerBase::executeAction(Action *action) { ReturnValue_t DeviceHandlerBase::executeAction(Action* action) {
ReturnValue_t result = acceptExternalDeviceCommands(); ReturnValue_t result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -1508,3 +1506,9 @@ MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyI
} }
return commandIter->second.sendReplyTo; return commandIter->second.sendReplyTo;
} }
ModeHelper const* DeviceHandlerBase::getModeHelper() const { return &modeHelper; }
ModeDefinitionHelper DeviceHandlerBase::getModeDefinitionHelper() {
return ModeDefinitionHelper::create<DeviceHandlerMode, DefaultSubmode>();
}

View File

@ -207,7 +207,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
Mode_t getTransitionSourceMode() const; Mode_t getTransitionSourceMode() const;
Submode_t getTransitionSourceSubMode() 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(); HealthState getHealth();
ReturnValue_t setHealth(HealthState health); ReturnValue_t setHealth(HealthState health);
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,

View File

@ -4,6 +4,7 @@
#include "../action/HasActionsIF.h" #include "../action/HasActionsIF.h"
#include "../datapoollocal/localPoolDefinitions.h" #include "../datapoollocal/localPoolDefinitions.h"
#include "../events/Event.h" #include "../events/Event.h"
#include "../introspection/ClasslessEnum.h"
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
#include "../modes/HasModesIF.h" #include "../modes/HasModesIF.h"
#include "DeviceHandlerMessage.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 * 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 * handler. MODE_ON and MODE_OFF are included in hasModesIF.h
*/ */
FSFW_CLASSLESS_ENUM(
// MODE_ON = 0, //!< The device is powered and ready to perform operations. In this mode, no DeviceHandlerMode, Mode_t,
// commands are sent by the device handler itself, but direct commands van be commanded and will //! The device is powered and ready to perform operations. In this mode, no
// be interpreted MODE_OFF = 1, //!< The device is powered off. The only command accepted in this //! commands are sent by the device handler itself, but direct commands can be
// mode is a mode change to on. //! 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 //! The device is powered on and the device handler periodically sends
//! commands. The commands to be sent are selected by the handler //! commands. The commands to be sent are selected by the handler
//! according to the submode. //! according to the submode.
static const Mode_t MODE_NORMAL = 2; ((MODE_NORMAL, 2, "Normal"))
//! The device is powered on and ready to perform operations. In this mode, //! 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 //! raw commands can be sent. The device handler will send all replies
//! received from the command back to the commanding object. //! received from the command back to the commanding object as raw TM
static const Mode_t MODE_RAW = 3; ((MODE_RAW, 3, "Raw"))
//! The device is shut down but the switch could not be turned off, so the //! 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 //! 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. //! can be commanded, which tries to switch off the device again.
static const Mode_t MODE_ERROR_ON = 4; ((MODE_ERROR_ON, 4, "Error")))
//! This is a transitional state which can not be commanded. The device //! 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 //! 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. //! perform commands. When this is completed, the mode changes to @c MODE_ON.

View File

@ -4,9 +4,10 @@
#include <cstdint> #include <cstdint>
#include "../events/Event.h" #include "../events/Event.h"
#include "../introspection/ClasslessEnum.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "ModeHelper.h"
#include "ModeDefinitionHelper.h" #include "ModeDefinitionHelper.h"
#include "ModeHelper.h"
#include "ModeMessage.h" #include "ModeMessage.h"
class HasModesIF { class HasModesIF {
@ -45,11 +46,14 @@ class HasModesIF {
//!< interpreted //!< interpreted
static const Mode_t MODE_OFF = 0; //!< The device is powered off. The only command accepted in static const Mode_t MODE_OFF = 0; //!< The device is powered off. The only command accepted in
//!< this mode is a mode change to on. //!< this mode is a mode change to on.
static const Submode_t SUBMODE_NONE = 0; //!< To avoid checks against magic number "0". FSFW_CLASSLESS_ENUM(DefaultSubmode, Submode_t,
((SUBMODE_NONE, 0,
"Default"))) //!< To avoid checks against magic number "0".
virtual ~HasModesIF() {} virtual ~HasModesIF() {}
virtual MessageQueueId_t getCommandQueue() const = 0; 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; virtual void getMode(Mode_t *mode, Submode_t *submode) = 0;
protected: protected: