diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index d7c340f4d..2c6f61e4a 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -12,7 +12,7 @@ ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId, mode(MODE_OFF), submode(SUBMODE_NONE), modeHelper(this), - healthHelper(this, setObjectId) { + healthHelper(this, setObjectId), actionHelper(this, commandQueue), datapoolHelper(this), housekeepingHelper(this) { commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth); } @@ -45,6 +45,21 @@ ReturnValue_t ControllerBase::initialize() { return result; } + result = actionHelper.initialize(); + if (result != returnvalue::OK) { + return result; + } + + result = housekeepingHelper.initialize(); + if (result != returnvalue::OK) { + return result; + } + + result = datapoolHelper.initialize(); + if (result != returnvalue::OK) { + return result; + } + return returnvalue::OK; } @@ -64,6 +79,12 @@ void ControllerBase::handleQueue() { if (result == returnvalue::OK) { continue; } + + result = actionHelper.handleActionMessage(&command); + if (result == returnvalue::OK) { + continue; + } + result = handleCommandMessage(&command); if (result == returnvalue::OK) { continue; diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 701c7e090..c8af55e37 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -1,14 +1,15 @@ #ifndef FSFW_CONTROLLER_CONTROLLERBASE_H_ #define FSFW_CONTROLLER_CONTROLLERBASE_H_ -#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" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tasks/PeriodicTaskIF.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include /** * @brief Generic base class for controller classes @@ -18,6 +19,8 @@ */ class ControllerBase : public HasModesIF, public HasHealthIF, + public HasDatapoolIF, + public HasActionsIF, public ExecutableObjectIF, public SystemObject { public: @@ -42,9 +45,17 @@ class ControllerBase : public HasModesIF, void setTaskIF(PeriodicTaskIF *task) override; ReturnValue_t initializeAfterTaskCreation() override; - /** HasModeIF override */ + /** HasModeIF overrides */ const ModeHelper *getModeHelper() const override; + /** HasActionsIF override */ + ActionHelper* getActionHelper() override; + ReturnValue_t executeAction(Action* action) override; + + /** HasDatapoolIF overrides */ + DatapoolHelper* getDatapoolHelper() override; + HousekeepingHelper* getHousekeepingHelper() override; + protected: /** * Implemented by child class. Handle command messages which are not @@ -74,6 +85,12 @@ class ControllerBase : public HasModesIF, HealthHelper healthHelper; + ActionHelper actionHelper; + + DatapoolHelper datapoolHelper; + + HousekeepingHelper housekeepingHelper; + /** * Pointer to the task which executes this component, * is invalid before setTaskIF was called. diff --git a/src/fsfw/datapool/DatasetEntry.h b/src/fsfw/datapool/DatasetEntry.h index f42e1df58..29a3d59d6 100644 --- a/src/fsfw/datapool/DatasetEntry.h +++ b/src/fsfw/datapool/DatasetEntry.h @@ -25,7 +25,7 @@ class DatasetEntry : public Parameter, public DatasetEntryIF { return; } storedValue = new T(); - storedValid = new bool + storedValid = new bool; } public: @@ -48,6 +48,8 @@ class DatasetEntry : public Parameter, public DatasetEntryIF { virtual bool getValid() { return valid; } + T value; //TODO can this be private? + protected: virtual void commit() { *storedValue = value; @@ -59,7 +61,7 @@ class DatasetEntry : public Parameter, public DatasetEntryIF { } virtual void connect(DatasetEntryIF *entry) { - HousekeepingEntry *theOther = dynamic_cast *>(entry); + DatasetEntry *theOther = dynamic_cast *>(entry); if (theOther == nullptr) { // Configuration error return; @@ -71,7 +73,7 @@ class DatasetEntry : public Parameter, public DatasetEntryIF { virtual bool changed() { return ((value != *storedValue) || (valid != *storedValid)); } private: - T value; + T *storedValue; bool *storedValid; bool valid; diff --git a/src/fsfw/datapool/DatasetEntryIF.h b/src/fsfw/datapool/DatasetEntryIF.h index 93b6502bf..c9ade73a0 100644 --- a/src/fsfw/datapool/DatasetEntryIF.h +++ b/src/fsfw/datapool/DatasetEntryIF.h @@ -26,10 +26,6 @@ class DatasetEntryIF { virtual void read() = 0; virtual void connect(DatasetEntryIF* entry) = 0; - /** - * create actualValue - */ - virtual void allocate() = 0; /** * returns if value and actual value is different