fsfw/src/fsfw/power/PowerSwitcherComponent.h

73 lines
2.6 KiB
C
Raw Normal View History

#pragma once
2022-04-01 17:27:53 +02:00
#include <fsfw/health/HasHealthIF.h>
#include <fsfw/health/HealthHelper.h>
#include <fsfw/modes/HasModesIF.h>
#include <fsfw/modes/ModeHelper.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/power/PowerSwitcher.h>
2022-05-16 14:55:15 +02:00
#include <fsfw/power/definitions.h>
2022-11-10 15:38:34 +01:00
#include <fsfw/subsystem/ModeTreeChildIF.h>
#include <fsfw/subsystem/ModeTreeConnectionIF.h>
2022-04-01 17:27:53 +02:00
#include <fsfw/tasks/ExecutableObjectIF.h>
class PowerSwitchIF;
/**
* @brief Allows to create an power switch object with its own mode and health
* @details
* This basic component allows to create an object which is solely responsible for managing a
* switch. It also has a mode and a health by implementing the respective interface components
* which allows integrating this component into a system mode tree.
*
* Commanding this component to MODE_OFF will cause the switcher to turn the switch off while
* commanding in to MODE_ON will cause the switcher to turn the switch on.
*/
2022-05-16 14:55:15 +02:00
class PowerSwitcherComponent : public SystemObject,
public ExecutableObjectIF,
2022-11-10 15:38:34 +01:00
public ModeTreeChildIF,
public ModeTreeConnectionIF,
2022-05-16 14:55:15 +02:00
public HasModesIF,
public HasHealthIF {
public:
PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
power::Switch_t pwrSwitch);
2022-11-10 15:38:34 +01:00
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF &getModeTreeChildIF() override;
protected:
PowerSwitcher switcher;
2022-05-16 14:55:15 +02:00
private:
MessageQueueIF *queue = nullptr;
2022-04-01 17:27:53 +02:00
Mode_t mode = MODE_OFF;
Submode_t submode = 0;
ModeHelper modeHelper;
HealthHelper healthHelper;
void setMode(Mode_t newMode, Submode_t newSubmode);
ReturnValue_t performOperation(uint8_t opCode) override;
2022-04-01 17:27:53 +02:00
ReturnValue_t initialize() override;
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
2022-04-01 17:27:53 +02:00
void getMode(Mode_t *mode, Submode_t *submode) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
2022-05-16 14:55:15 +02:00
uint32_t *msToReachTheMode) override;
2022-04-01 17:27:53 +02:00
void startTransition(Mode_t mode, Submode_t submode) override;
virtual void performFaultyOperation();
2022-04-01 17:27:53 +02:00
void setToExternalControl() override;
void announceMode(bool recursive) override;
ReturnValue_t setHealth(HealthState health) override;
HasHealthIF::HealthState getHealth() override;
2022-11-10 15:38:34 +01:00
[[nodiscard]] object_id_t getObjectId() const override;
[[nodiscard]] const HasHealthIF *getOptHealthIF() const override;
[[nodiscard]] const HasModesIF &getModeIF() const override;
2022-04-01 17:27:53 +02:00
};