fixes for switchig algorithm
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-01-10 11:13:34 +01:00
parent 8fde9ee9be
commit fca45014e4
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 35 additions and 17 deletions

View File

@ -34,7 +34,7 @@ void PayloadPcduHandler::doStartUp() {
state = States::STACK_5V_SWITCHING;
}
if (state == States::STACK_5V_SWITCHING) {
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::PL_PCDU);
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::PL_PCDU, true);
if (retval == BUSY) {
return;
}
@ -62,7 +62,7 @@ void PayloadPcduHandler::doShutDown() {
}
if (state == States::STACK_5V_SWITCHING) {
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::PL_PCDU);
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::PL_PCDU, true);
if (retval == BUSY) {
return;
}

View File

@ -21,7 +21,7 @@ RadiationSensorHandler::~RadiationSensorHandler() {}
void RadiationSensorHandler::doStartUp() {
if (internalState == InternalState::OFF) {
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::RAD_SENSOR);
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::RAD_SENSOR, true);
if (retval == BUSY) {
return;
}
@ -42,7 +42,7 @@ void RadiationSensorHandler::doStartUp() {
}
void RadiationSensorHandler::doShutDown() {
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::RAD_SENSOR);
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::RAD_SENSOR, true);
if (retval == BUSY) {
return;
}

View File

@ -4,8 +4,11 @@ Stack5VHandler::Stack5VHandler(PowerSwitchIF& switcher) : switcher(switcher) {
stackLock = MutexFactory::instance()->createMutex();
}
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateStates) {
MutexGuard mg(stackLock);
if (updateStates) {
updateInternalStates();
}
if (switchIsOn) {
if (commander == StackCommander::PL_PCDU) {
plPcduIsOn = true;
@ -21,8 +24,11 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
return switcher.sendSwitchCommand(stackSwitch, PowerSwitchIF::SWITCH_ON);
}
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateStates) {
MutexGuard mg(stackLock);
if (updateStates) {
updateInternalStates();
}
if (not switchIsOn) {
if (commander == StackCommander::PL_PCDU) {
plPcduIsOn = false;
@ -44,6 +50,15 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
bool Stack5VHandler::isSwitchOn() {
MutexGuard mg(stackLock);
return updateInternalStates();
}
void Stack5VHandler::update() {
MutexGuard mg(stackLock);
updateInternalStates();
}
bool Stack5VHandler::updateInternalStates() {
if (switcher.getSwitchState(stackSwitch) == PowerSwitchIF::SWITCH_ON) {
if (not switchIsOn) {
if (handlerState == HandlerState::SWITCH_PENDING) {
@ -52,7 +67,7 @@ bool Stack5VHandler::isSwitchOn() {
switchIsOn = true;
}
return true;
} else {
}
if (switchIsOn) {
if (handlerState == HandlerState::SWITCH_PENDING) {
handlerState = HandlerState::IDLE;
@ -61,6 +76,6 @@ bool Stack5VHandler::isSwitchOn() {
}
radSensorIsOn = false;
plPcduIsOn = false;
}
return false;
}

View File

@ -13,10 +13,11 @@ class Stack5VHandler {
static constexpr ReturnValue_t BUSY = returnvalue::makeCode(1, 0);
Stack5VHandler(PowerSwitchIF& switcher);
ReturnValue_t deviceToOn(StackCommander commander);
ReturnValue_t deviceToOff(StackCommander commander);
ReturnValue_t deviceToOn(StackCommander commander, bool updateStates);
ReturnValue_t deviceToOff(StackCommander commander, bool updateStates);
bool isSwitchOn();
void update();
private:
MutexIF* stackLock;
@ -26,6 +27,8 @@ class Stack5VHandler {
bool radSensorIsOn = false;
bool plPcduIsOn = false;
pcdu::Switches stackSwitch = pcdu::Switches::P60_DOCK_5V_STACK;
bool updateInternalStates();
};
#endif /* MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_ */