1
0
forked from fsfw/fsfw

added extended controller base

This commit is contained in:
2020-10-10 20:04:01 +02:00
parent 670e9bfa0f
commit 3e79d2e73a
4 changed files with 201 additions and 17 deletions

View File

@@ -11,9 +11,10 @@
#include "../datapool/HkSwitchHelper.h"
/**
* @brief Generic base class for controller classes
* @brief Generic base class for controller classes
* @details
* Implements common interfaces for controllers.
* Implements common interfaces for controllers, which generally have
* a mode and a health state. This avoids boilerplate code.
*/
class ControllerBase: public HasModesIF,
public HasHealthIF,
@@ -27,24 +28,18 @@ public:
size_t commandQueueDepth = 3);
virtual ~ControllerBase();
/** SystemObject override */
virtual ReturnValue_t initialize() override;
virtual MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t performOperation(uint8_t opCode) override;
/** HasHealthIF overrides */
virtual ReturnValue_t setHealth(HealthState health) override;
virtual HasHealthIF::HealthState getHealth() override;
/**
* Implementation of ExecutableObjectIF function
*
* Used to setup the reference of the task, that executes this component
* @param task_ Pointer to the taskIF of this task
*/
virtual void setTaskIF(PeriodicTaskIF* task_) override;
/** ExecutableObjectIF overrides */
virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual void setTaskIF(PeriodicTaskIF* task) override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
protected:
@@ -57,6 +52,9 @@ protected:
*/
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
/**
* Periodic helper, implemented by child class.
*/
virtual void performControlOperation() = 0;
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
@@ -74,6 +72,7 @@ protected:
HealthHelper healthHelper;
// Is this still needed?
HkSwitchHelper hkSwitcher;
/**
@@ -82,13 +81,16 @@ protected:
*/
PeriodicTaskIF* executingTask = nullptr;
void handleQueue();
/** Handle mode and health messages */
virtual void handleQueue();
/** Mode helpers */
virtual void modeChanged(Mode_t mode, Submode_t submode);
virtual void startTransition(Mode_t mode, Submode_t submode);
virtual void getMode(Mode_t *mode, Submode_t *submode);
virtual void setToExternalControl();
virtual void announceMode(bool recursive);
/** HK helpers */
virtual void changeHK(Mode_t mode, Submode_t submode, bool enable);
};