2022-12-21 14:11:31 +01:00
|
|
|
#ifndef MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_
|
|
|
|
#define MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_
|
|
|
|
|
|
|
|
#include <fsfw/power/PowerSwitchIF.h>
|
|
|
|
|
|
|
|
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
|
|
|
|
2022-12-21 14:34:07 +01:00
|
|
|
enum class StackCommander { RAD_SENSOR = 0, PL_PCDU = 1 };
|
2022-12-21 14:43:12 +01:00
|
|
|
enum class HandlerState { SWITCH_PENDING, IDLE };
|
2022-12-21 14:34:07 +01:00
|
|
|
|
2022-12-21 14:11:31 +01:00
|
|
|
class Stack5VHandler {
|
|
|
|
public:
|
2023-02-23 15:40:06 +01:00
|
|
|
//! [EXPORT] : [SKIP]
|
2022-12-21 17:30:21 +01:00
|
|
|
static constexpr ReturnValue_t BUSY = returnvalue::makeCode(1, 0);
|
2022-12-21 14:11:31 +01:00
|
|
|
Stack5VHandler(PowerSwitchIF& switcher);
|
|
|
|
|
2023-01-10 11:13:34 +01:00
|
|
|
ReturnValue_t deviceToOn(StackCommander commander, bool updateStates);
|
|
|
|
ReturnValue_t deviceToOff(StackCommander commander, bool updateStates);
|
2022-12-21 14:11:31 +01:00
|
|
|
|
|
|
|
bool isSwitchOn();
|
2023-01-10 11:13:34 +01:00
|
|
|
void update();
|
2022-12-21 14:11:31 +01:00
|
|
|
|
|
|
|
private:
|
2023-03-02 15:32:12 +01:00
|
|
|
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
|
|
|
|
static constexpr uint32_t LOCK_TIMEOUT = 20;
|
|
|
|
|
2022-12-21 14:34:07 +01:00
|
|
|
MutexIF* stackLock;
|
2023-03-02 15:32:12 +01:00
|
|
|
static constexpr char LOCK_CTX[] = "Stack5VHandler";
|
2022-12-21 14:11:31 +01:00
|
|
|
PowerSwitchIF& switcher;
|
2022-12-21 14:43:12 +01:00
|
|
|
bool switchIsOn = false;
|
2023-01-10 15:04:49 +01:00
|
|
|
bool targetState = false;
|
2022-12-21 14:43:12 +01:00
|
|
|
HandlerState handlerState = HandlerState::IDLE;
|
2022-12-21 14:11:31 +01:00
|
|
|
bool radSensorIsOn = false;
|
|
|
|
bool plPcduIsOn = false;
|
2023-03-16 18:47:51 +01:00
|
|
|
power::Switches stackSwitch = power::Switches::P60_DOCK_5V_STACK;
|
2023-01-10 11:13:34 +01:00
|
|
|
|
|
|
|
bool updateInternalStates();
|
2022-12-21 14:11:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_ */
|