add FDIR handling

This commit is contained in:
Robin Müller 2023-11-09 11:04:45 +01:00
parent 133ca51d18
commit 18cc870c8e
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 72 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#include "FreshDeviceHandlerBase.h" #include "FreshDeviceHandlerBase.h"
#include "fsfw/devicehandlers/DeviceHandlerFailureIsolation.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/subsystem/helper.h" #include "fsfw/subsystem/helper.h"
@ -8,13 +9,17 @@ FreshDeviceHandlerBase::FreshDeviceHandlerBase(DhbConfig config)
actionHelper(this, nullptr), actionHelper(this, nullptr),
modeHelper(this), modeHelper(this),
healthHelper(this, getObjectId()), healthHelper(this, getObjectId()),
poolManager(this, nullptr) { poolManager(this, nullptr),
defaultFdirParent(config.defaultFdirParent) {
auto mqArgs = MqArgs(config.objectId, static_cast<void*>(this)); auto mqArgs = MqArgs(config.objectId, static_cast<void*>(this));
messageQueue = QueueFactory::instance()->createMessageQueue( messageQueue = QueueFactory::instance()->createMessageQueue(
config.msgQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); config.msgQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
} }
FreshDeviceHandlerBase::~FreshDeviceHandlerBase() { FreshDeviceHandlerBase::~FreshDeviceHandlerBase() {
QueueFactory::instance()->deleteMessageQueue(messageQueue); QueueFactory::instance()->deleteMessageQueue(messageQueue);
if (not hasCustomFdir) {
delete fdirInstance;
}
} }
[[nodiscard]] object_id_t FreshDeviceHandlerBase::getObjectId() const { [[nodiscard]] object_id_t FreshDeviceHandlerBase::getObjectId() const {
@ -118,6 +123,17 @@ ReturnValue_t FreshDeviceHandlerBase::setHealth(HasHealthIF::HealthState health)
return returnvalue::OK; return returnvalue::OK;
} }
void FreshDeviceHandlerBase::triggerEvent(Event event, uint32_t parameter1, uint32_t parameter2) {
fdirInstance->triggerEvent(event, parameter1, parameter2);
}
void FreshDeviceHandlerBase::forwardEvent(Event event, uint32_t parameter1,
uint32_t parameter2) const {
fdirInstance->triggerEvent(event, parameter1, parameter2);
}
void FreshDeviceHandlerBase::setToExternalControl() { setHealth(HealthState::EXTERNAL_CONTROL); }
// System Object overrides. // System Object overrides.
ReturnValue_t FreshDeviceHandlerBase::initialize() { ReturnValue_t FreshDeviceHandlerBase::initialize() {
ReturnValue_t result = modeHelper.initialize(); ReturnValue_t result = modeHelper.initialize();
@ -137,6 +153,25 @@ ReturnValue_t FreshDeviceHandlerBase::initialize() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
if (fdirInstance == nullptr) {
hasCustomFdir = false;
fdirInstance = new DeviceHandlerFailureIsolation(getObjectId(), defaultFdirParent);
}
result = fdirInstance->initialize();
if (result != returnvalue::OK) {
return result;
}
return SystemObject::initialize(); return SystemObject::initialize();
} }
void FreshDeviceHandlerBase::setToExternalControl() { setHealth(HealthState::EXTERNAL_CONTROL); } ReturnValue_t FreshDeviceHandlerBase::getParameter(uint8_t domainId, uint8_t uniqueId,
ParameterWrapper* parameterWrapper,
const ParameterWrapper* newValues,
uint16_t startAtIndex) {
ReturnValue_t result =
fdirInstance->getParameter(domainId, uniqueId, parameterWrapper, newValues, startAtIndex);
if (result != INVALID_DOMAIN_ID) {
return result;
}
return INVALID_DOMAIN_ID;
}

View File

@ -4,6 +4,7 @@
#include "fsfw/datapoollocal/HasLocalDataPoolIF.h" #include "fsfw/datapoollocal/HasLocalDataPoolIF.h"
#include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/fdir/FailureIsolationBase.h"
#include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HasHealthIF.h"
#include "fsfw/health/HealthHelper.h" #include "fsfw/health/HealthHelper.h"
#include "fsfw/modes/HasModesIF.h" #include "fsfw/modes/HasModesIF.h"
@ -16,8 +17,9 @@
struct DhbConfig { struct DhbConfig {
explicit DhbConfig(object_id_t objectId) : objectId(objectId) {} explicit DhbConfig(object_id_t objectId) : objectId(objectId) {}
object_id_t objectId; object_id_t objectId;
FailureIsolationBase* fdirInstance = nullptr;
object_id_t defaultFdirParent = objects::NO_OBJECT;
uint32_t msgQueueDepth = 10; uint32_t msgQueueDepth = 10;
}; };
class FreshDeviceHandlerBase : public SystemObject, class FreshDeviceHandlerBase : public SystemObject,
@ -28,6 +30,7 @@ class FreshDeviceHandlerBase : public SystemObject,
public ModeTreeChildIF, public ModeTreeChildIF,
public ModeTreeConnectionIF, public ModeTreeConnectionIF,
public HasActionsIF, public HasActionsIF,
public HasParametersIF,
public HasLocalDataPoolIF { public HasLocalDataPoolIF {
public: public:
explicit FreshDeviceHandlerBase(DhbConfig config); explicit FreshDeviceHandlerBase(DhbConfig config);
@ -68,6 +71,10 @@ class FreshDeviceHandlerBase : public SystemObject,
HealthHelper healthHelper; HealthHelper healthHelper;
LocalDataPoolManager poolManager; LocalDataPoolManager poolManager;
bool hasCustomFdir = false;
FailureIsolationBase* fdirInstance;
object_id_t defaultFdirParent;
/** /**
* Pointer to the task which executes this component, * Pointer to the task which executes this component,
* is invalid before setTaskIF was called. * is invalid before setTaskIF was called.
@ -107,6 +114,33 @@ class FreshDeviceHandlerBase : public SystemObject,
ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initializeAfterTaskCreation() override; ReturnValue_t initializeAfterTaskCreation() override;
/**
* This calls the FDIR instance event trigger function.
* @param event
* @param parameter1
* @param parameter2
*/
void triggerEvent(Event event, uint32_t parameter1, uint32_t parameter2) override;
/**
* This calls the FDIR instance event forward function.
* @param event
* @param parameter1
* @param parameter2
*/
void forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const override;
/**
* This implementation handles the FDIR parameters. The user can override this to handle
* custom parameters.
* @param domainId
* @param uniqueId
* @param parameterWrapper
* @param newValues
* @param startAtIndex
* @return
*/
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper,
const ParameterWrapper* newValues, uint16_t startAtIndex) override;
private: private:
// Executable Overrides. // Executable Overrides.
void setTaskIF(PeriodicTaskIF* task) override; void setTaskIF(PeriodicTaskIF* task) override;