some more bugfixes
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -9,6 +9,9 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateSt
|
||||
if (updateStates) {
|
||||
updateInternalStates();
|
||||
}
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
return BUSY;
|
||||
}
|
||||
if (switchIsOn) {
|
||||
if (commander == StackCommander::PL_PCDU) {
|
||||
plPcduIsOn = true;
|
||||
@ -17,10 +20,9 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateSt
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
return BUSY;
|
||||
}
|
||||
|
||||
handlerState = HandlerState::SWITCH_PENDING;
|
||||
targetState = true;
|
||||
return switcher.sendSwitchCommand(stackSwitch, PowerSwitchIF::SWITCH_ON);
|
||||
}
|
||||
|
||||
@ -29,6 +31,11 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateS
|
||||
if (updateStates) {
|
||||
updateInternalStates();
|
||||
}
|
||||
// wait for our turn
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
return BUSY;
|
||||
}
|
||||
// If the switch is already off, we are done
|
||||
if (not switchIsOn) {
|
||||
if (commander == StackCommander::PL_PCDU) {
|
||||
plPcduIsOn = false;
|
||||
@ -37,14 +44,13 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateS
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
return BUSY;
|
||||
}
|
||||
// If one device is still on, do not turn off the switch
|
||||
if ((commander == StackCommander::PL_PCDU and radSensorIsOn) or
|
||||
(commander == StackCommander::RAD_SENSOR and plPcduIsOn)) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
handlerState = HandlerState::SWITCH_PENDING;
|
||||
targetState = false;
|
||||
return switcher.sendSwitchCommand(stackSwitch, PowerSwitchIF::SWITCH_OFF);
|
||||
}
|
||||
|
||||
@ -60,22 +66,16 @@ void Stack5VHandler::update() {
|
||||
|
||||
bool Stack5VHandler::updateInternalStates() {
|
||||
if (switcher.getSwitchState(stackSwitch) == PowerSwitchIF::SWITCH_ON) {
|
||||
if (not switchIsOn) {
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
handlerState = HandlerState::IDLE;
|
||||
}
|
||||
if (handlerState == HandlerState::SWITCH_PENDING and targetState) {
|
||||
handlerState = HandlerState::IDLE;
|
||||
switchIsOn = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (switchIsOn) {
|
||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||
handlerState = HandlerState::IDLE;
|
||||
}
|
||||
} else if (handlerState == HandlerState::SWITCH_PENDING and not targetState) {
|
||||
handlerState = HandlerState::IDLE;
|
||||
switchIsOn = false;
|
||||
radSensorIsOn = false;
|
||||
plPcduIsOn = false;
|
||||
}
|
||||
radSensorIsOn = false;
|
||||
plPcduIsOn = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user