fixes for switchig algorithm
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:
parent
8fde9ee9be
commit
fca45014e4
@ -34,7 +34,7 @@ void PayloadPcduHandler::doStartUp() {
|
|||||||
state = States::STACK_5V_SWITCHING;
|
state = States::STACK_5V_SWITCHING;
|
||||||
}
|
}
|
||||||
if (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) {
|
if (retval == BUSY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ void PayloadPcduHandler::doShutDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state == States::STACK_5V_SWITCHING) {
|
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) {
|
if (retval == BUSY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ RadiationSensorHandler::~RadiationSensorHandler() {}
|
|||||||
|
|
||||||
void RadiationSensorHandler::doStartUp() {
|
void RadiationSensorHandler::doStartUp() {
|
||||||
if (internalState == InternalState::OFF) {
|
if (internalState == InternalState::OFF) {
|
||||||
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::RAD_SENSOR);
|
ReturnValue_t retval = stackHandler.deviceToOn(StackCommander::RAD_SENSOR, true);
|
||||||
if (retval == BUSY) {
|
if (retval == BUSY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ void RadiationSensorHandler::doStartUp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RadiationSensorHandler::doShutDown() {
|
void RadiationSensorHandler::doShutDown() {
|
||||||
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::RAD_SENSOR);
|
ReturnValue_t retval = stackHandler.deviceToOff(StackCommander::RAD_SENSOR, true);
|
||||||
if (retval == BUSY) {
|
if (retval == BUSY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,11 @@ Stack5VHandler::Stack5VHandler(PowerSwitchIF& switcher) : switcher(switcher) {
|
|||||||
stackLock = MutexFactory::instance()->createMutex();
|
stackLock = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
|
ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander, bool updateStates) {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock);
|
||||||
|
if (updateStates) {
|
||||||
|
updateInternalStates();
|
||||||
|
}
|
||||||
if (switchIsOn) {
|
if (switchIsOn) {
|
||||||
if (commander == StackCommander::PL_PCDU) {
|
if (commander == StackCommander::PL_PCDU) {
|
||||||
plPcduIsOn = true;
|
plPcduIsOn = true;
|
||||||
@ -21,8 +24,11 @@ ReturnValue_t Stack5VHandler::deviceToOn(StackCommander commander) {
|
|||||||
return switcher.sendSwitchCommand(stackSwitch, PowerSwitchIF::SWITCH_ON);
|
return switcher.sendSwitchCommand(stackSwitch, PowerSwitchIF::SWITCH_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
|
ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander, bool updateStates) {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock);
|
||||||
|
if (updateStates) {
|
||||||
|
updateInternalStates();
|
||||||
|
}
|
||||||
if (not switchIsOn) {
|
if (not switchIsOn) {
|
||||||
if (commander == StackCommander::PL_PCDU) {
|
if (commander == StackCommander::PL_PCDU) {
|
||||||
plPcduIsOn = false;
|
plPcduIsOn = false;
|
||||||
@ -44,6 +50,15 @@ ReturnValue_t Stack5VHandler::deviceToOff(StackCommander commander) {
|
|||||||
|
|
||||||
bool Stack5VHandler::isSwitchOn() {
|
bool Stack5VHandler::isSwitchOn() {
|
||||||
MutexGuard mg(stackLock);
|
MutexGuard mg(stackLock);
|
||||||
|
return updateInternalStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stack5VHandler::update() {
|
||||||
|
MutexGuard mg(stackLock);
|
||||||
|
updateInternalStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Stack5VHandler::updateInternalStates() {
|
||||||
if (switcher.getSwitchState(stackSwitch) == PowerSwitchIF::SWITCH_ON) {
|
if (switcher.getSwitchState(stackSwitch) == PowerSwitchIF::SWITCH_ON) {
|
||||||
if (not switchIsOn) {
|
if (not switchIsOn) {
|
||||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||||
@ -52,7 +67,7 @@ bool Stack5VHandler::isSwitchOn() {
|
|||||||
switchIsOn = true;
|
switchIsOn = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
if (switchIsOn) {
|
if (switchIsOn) {
|
||||||
if (handlerState == HandlerState::SWITCH_PENDING) {
|
if (handlerState == HandlerState::SWITCH_PENDING) {
|
||||||
handlerState = HandlerState::IDLE;
|
handlerState = HandlerState::IDLE;
|
||||||
@ -61,6 +76,6 @@ bool Stack5VHandler::isSwitchOn() {
|
|||||||
}
|
}
|
||||||
radSensorIsOn = false;
|
radSensorIsOn = false;
|
||||||
plPcduIsOn = false;
|
plPcduIsOn = false;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,11 @@ class Stack5VHandler {
|
|||||||
static constexpr ReturnValue_t BUSY = returnvalue::makeCode(1, 0);
|
static constexpr ReturnValue_t BUSY = returnvalue::makeCode(1, 0);
|
||||||
Stack5VHandler(PowerSwitchIF& switcher);
|
Stack5VHandler(PowerSwitchIF& switcher);
|
||||||
|
|
||||||
ReturnValue_t deviceToOn(StackCommander commander);
|
ReturnValue_t deviceToOn(StackCommander commander, bool updateStates);
|
||||||
ReturnValue_t deviceToOff(StackCommander commander);
|
ReturnValue_t deviceToOff(StackCommander commander, bool updateStates);
|
||||||
|
|
||||||
bool isSwitchOn();
|
bool isSwitchOn();
|
||||||
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MutexIF* stackLock;
|
MutexIF* stackLock;
|
||||||
@ -26,6 +27,8 @@ class Stack5VHandler {
|
|||||||
bool radSensorIsOn = false;
|
bool radSensorIsOn = false;
|
||||||
bool plPcduIsOn = false;
|
bool plPcduIsOn = false;
|
||||||
pcdu::Switches stackSwitch = pcdu::Switches::P60_DOCK_5V_STACK;
|
pcdu::Switches stackSwitch = pcdu::Switches::P60_DOCK_5V_STACK;
|
||||||
|
|
||||||
|
bool updateInternalStates();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_ */
|
#endif /* MISSION_SYSTEM_OBJECTS_STACK5VHANDLER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user