2020-12-03 18:29:28 +01:00
|
|
|
#ifndef FSFW_POWER_POWERSWITCHER_H_
|
|
|
|
#define FSFW_POWER_POWERSWITCHER_H_
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "PowerSwitchIF.h"
|
2020-12-03 18:29:28 +01:00
|
|
|
|
|
|
|
#include "../objectmanager/SystemObjectIF.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "../timemanager/Countdown.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-12-03 18:29:28 +01:00
|
|
|
class PowerSwitcher: public HasReturnvaluesIF {
|
2016-06-15 23:48:41 +02:00
|
|
|
public:
|
|
|
|
enum State_t {
|
|
|
|
WAIT_OFF,
|
|
|
|
WAIT_ON,
|
|
|
|
SWITCH_IS_OFF,
|
|
|
|
SWITCH_IS_ON,
|
|
|
|
};
|
|
|
|
State_t state;
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER;
|
2016-06-15 23:48:41 +02:00
|
|
|
static const ReturnValue_t IN_POWER_TRANSITION = MAKE_RETURN_CODE(1);
|
|
|
|
static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2);
|
2020-12-03 18:29:28 +01:00
|
|
|
PowerSwitcher( uint8_t setSwitch1, uint8_t setSwitch2 = NO_SWITCH,
|
|
|
|
State_t setStartState = SWITCH_IS_OFF );
|
2018-07-12 16:29:32 +02:00
|
|
|
ReturnValue_t initialize(object_id_t powerSwitchId);
|
2016-06-15 23:48:41 +02:00
|
|
|
void turnOn();
|
|
|
|
void turnOff();
|
|
|
|
void doStateMachine();
|
|
|
|
State_t getState();
|
|
|
|
ReturnValue_t checkSwitchState();
|
|
|
|
uint32_t getSwitchDelay();
|
|
|
|
uint8_t getFirstSwitch() const;
|
|
|
|
uint8_t getSecondSwitch() const;
|
|
|
|
private:
|
|
|
|
uint8_t firstSwitch;
|
|
|
|
uint8_t secondSwitch;
|
2020-12-03 18:29:28 +01:00
|
|
|
PowerSwitchIF* power = nullptr;
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
static const uint8_t NO_SWITCH = 0xFF;
|
|
|
|
enum SwitchReturn_t {
|
|
|
|
ONE_SWITCH = 1,
|
|
|
|
TWO_SWITCHES = 2
|
|
|
|
};
|
|
|
|
ReturnValue_t getStateOfSwitches();
|
|
|
|
void commandSwitches( ReturnValue_t onOff );
|
|
|
|
SwitchReturn_t howManySwitches();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-03 18:29:28 +01:00
|
|
|
#endif /* FSFW_POWER_POWERSWITCHER_H_ */
|