this is annoying
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-12-21 14:43:12 +01:00
parent 164bfc3521
commit dcf6367314
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 29 additions and 3 deletions

View File

@ -6,7 +6,7 @@ Stack5VHandler::Stack5VHandler(PowerSwitchIF& switcher) : switcher(switcher) {
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
MutexGuard mg(stackLock);
if (radSensorIsOn or plPcduIsOn) {
if (switchIsOn or handlerState == HandlerState::SWITCH_PENDING) {
return returnvalue::OK;
}
if (commander == StackCommander::PL_PCDU) {
@ -19,7 +19,7 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
MutexGuard mg(stackLock);
if (not radSensorIsOn and not plPcduIsOn and not plPcduCommandedOn and not radSensorCommandedOn) {
if (not switchIsOn) {
return returnvalue::OK;
}
if (commander == StackCommander::PL_PCDU) {
@ -33,7 +33,30 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
bool Stack5VHandler::isSwitchOn() {
MutexGuard mg(stackLock);
if (switcher.getSwitchState(stackSwitch) == PowerSwitchIF::SWITCH_ON) {
if (not switchIsOn) {
if (handlerState == HandlerState::SWITCH_PENDING) {
handlerState = HandlerState::IDLE;
}
switchIsOn = true;
}
if (plPcduCommandedOn) {
plPcduIsOn = true;
}
if (radSensorCommandedOn) {
radSensorIsOn = true;
}
return true;
} else {
if (switchIsOn) {
if (handlerState == HandlerState::SWITCH_PENDING) {
handlerState = HandlerState::IDLE;
}
switchIsOn = false;
}
radSensorIsOn = false;
plPcduIsOn = false;
radSensorCommandedOn = false;
plPcduCommandedOn = false;
}
return false;
}

View File

@ -6,6 +6,7 @@
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
enum class StackCommander { RAD_SENSOR = 0, PL_PCDU = 1 };
enum class HandlerState { SWITCH_PENDING, IDLE };
class Stack5VHandler {
public:
@ -19,8 +20,10 @@ class Stack5VHandler {
private:
MutexIF* stackLock;
PowerSwitchIF& switcher;
bool radSensorCommandedOn = false;
bool switchIsOn = false;
HandlerState handlerState = HandlerState::IDLE;
bool plPcduCommandedOn = false;
bool radSensorCommandedOn = false;
bool radSensorIsOn = false;
bool plPcduIsOn = false;
pcdu::Switches stackSwitch = pcdu::Switches::P60_DOCK_5V_STACK;