Merge remote-tracking branch 'sidestream/mohr_introspection' into mohr/introspection

This commit is contained in:
Ulrich Mohr 2022-08-26 15:52:14 +02:00
commit c7e6f01f9b
8 changed files with 69 additions and 32 deletions

View File

@ -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:

View File

@ -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

View File

@ -1325,9 +1325,7 @@ 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 result = acceptExternalDeviceCommands();
@ -1605,3 +1603,10 @@ void DeviceHandlerBase::disableCommandsAndReplies() {
}
}
}
ModeHelper const* DeviceHandlerBase::getModeHelper() const { return &modeHelper; }
ModeDefinitionHelper DeviceHandlerBase::getModeDefinitionHelper() {
return ModeDefinitionHelper::create<DeviceHandlerMode, DefaultSubmode>();
}

View File

@ -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,

View File

@ -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
*/
// 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.
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.
static const Mode_t MODE_NORMAL = 2;
((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.
static const Mode_t MODE_RAW = 3;
//! 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.
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
//! 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.

View File

@ -4,9 +4,10 @@
#include <cstdint>
#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,11 +47,13 @@ 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 const ModeHelper * getModeHelper() const = 0;
virtual ModeDefinitionHelper getModeDefinitionHelper() = 0;
virtual void getMode(Mode_t *mode, Submode_t *submode) = 0;

View File

@ -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;
}

View File

@ -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 {