this is going to be tricky

This commit is contained in:
Robin Müller 2023-03-01 20:12:48 +01:00
parent 0a7eb6f6bc
commit 73c594a930
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 25 additions and 22 deletions

View File

@ -104,28 +104,25 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s
using namespace duallane; using namespace duallane;
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
bool needsSecondStep = false; bool needsSecondStep = false;
if(sideSwitchTransition(mode, submode) and sideSwitchState == SideSwitchState::NONE) {
sideSwitchState = SideSwitchState::TO_DUAL;
}
// Switch to dual side first, and later switch back to the otherside
if(sideSwitchState == SideSwitchState::TO_DUAL) {
submode = Submodes::DUAL_MODE;
targetSubmodeForSideSwitch = static_cast<duallane::Submodes>(submode);
// TODO: Ugly hack. The base class should support arbitrary number of steps..
needsSecondStep = true;
} else if(sideSwitchState == SideSwitchState::DISABLE_OTHER_SIDE) {
submode = targetSubmodeForSideSwitch;
}
auto cmdSeq = [&](object_id_t objectId, Mode_t devMode, ModeTableIdx tableIdx) { auto cmdSeq = [&](object_id_t objectId, Mode_t devMode, ModeTableIdx tableIdx) {
if (mode == devMode) { if (mode == devMode) {
modeTable[tableIdx].setMode(mode); modeTable[tableIdx].setMode(mode);
} else if (mode == DeviceHandlerIF::MODE_NORMAL) { } else if (isUseable(objectId, devMode)) {
if (isUseable(objectId, devMode)) { modeTable[tableIdx].setMode(mode);
if (devMode == MODE_ON) {
modeTable[tableIdx].setMode(mode);
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
} else {
modeTable[tableIdx].setMode(MODE_ON);
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
if (internalState != STATE_SECOND_STEP) {
needsSecondStep = true;
}
}
}
} else if (mode == MODE_ON) {
if (isUseable(objectId, devMode)) {
modeTable[tableIdx].setMode(MODE_ON);
modeTable[tableIdx].setSubmode(SUBMODE_NONE); modeTable[tableIdx].setSubmode(SUBMODE_NONE);
} }
}
}; };
bool gpsUsable = isUseable(helper.gpsId, helper.gpsMode); bool gpsUsable = isUseable(helper.gpsId, helper.gpsMode);
switch (submode) { switch (submode) {

View File

@ -97,11 +97,7 @@ ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_
return returnvalue::FAILED; return returnvalue::FAILED;
} }
if (sideSwitchTransition(mode, submode)) { if (sideSwitchTransition(mode, submode)) {
// I could implement this but this would increase the already high complexity. This is not //inSideSwitchTransition = true;
// necessary. The operator should can send a command to switch the assembly off first and
// then send a command to turn on the other side, either to ON or to NORMAL
triggerEvent(SIDE_SWITCH_TRANSITION_NOT_ALLOWED_ID, 0, 0);
return TRANS_NOT_ALLOWED;
} }
return returnvalue::OK; return returnvalue::OK;
} }
@ -225,6 +221,7 @@ void DualLaneAssemblyBase::finishModeOp() {
pwrStateMachine.reset(); pwrStateMachine.reset();
powerRetryCounter = 0; powerRetryCounter = 0;
tryingOtherSide = false; tryingOtherSide = false;
sideSwitchState = SideSwitchState::NONE;
dualModeErrorSwitch = true; dualModeErrorSwitch = true;
} }

View File

@ -33,6 +33,15 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF {
bool dualModeErrorSwitch = true; bool dualModeErrorSwitch = true;
duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE; duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE;
enum SideSwitchState {
NONE,
TO_DUAL,
DISABLE_OTHER_SIDE
};
SideSwitchState sideSwitchState = SideSwitchState::NONE;
duallane::Submodes targetSubmodeForSideSwitch = duallane::Submodes::B_SIDE;
enum RecoveryCustomStates { enum RecoveryCustomStates {
IDLE, IDLE,
POWER_SWITCHING_OFF, POWER_SWITCHING_OFF,