bugfixes for NORMAL to OFF transition
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-03-07 18:39:33 +01:00
parent 597ab9c74c
commit 62229cb999
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
7 changed files with 85 additions and 79 deletions

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 113 translations. * Contains 113 translations.
* Generated on: 2022-03-07 17:04:59 * Generated on: 2022-03-07 17:15:28
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 113 translations. * Contains 113 translations.
* Generated on: 2022-03-07 17:04:59 * Generated on: 2022-03-07 17:15:28
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -7,7 +7,7 @@
AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId, AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId,
PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF) PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF)
: AssemblyBase(objectId, parentId), : AssemblyBase(objectId, parentId),
pwrStateMachine(SWITCH_A, SWITCH_B, switcher, state), pwrStateMachine(SWITCH_A, SWITCH_B, switcher),
helper(helper), helper(helper),
gpioIF(gpioIF) { gpioIF(gpioIF) {
if (switcher == nullptr) { if (switcher == nullptr) {
@ -32,35 +32,28 @@ AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId,
void AcsBoardAssembly::performChildOperation() { void AcsBoardAssembly::performChildOperation() {
using namespace duallane; using namespace duallane;
if (state == PwrStates::SWITCHING_POWER or state == PwrStates::CHECKING_POWER) { if (pwrStateMachine.active()) {
if (targetMode != MODE_OFF) { pwrStateMachineWrapper();
pwrStateMachineWrapper(targetMode, targetSubmode);
}
// This state is the indicator that the power state machine is done // This state is the indicator that the power state machine is done
if (state == PwrStates::MODE_COMMANDING) {
AssemblyBase::performChildOperation();
} }
} else { if (not pwrStateMachine.active()) {
AssemblyBase::performChildOperation(); AssemblyBase::performChildOperation();
// This state is the indicator that the mode state machine is done
if (state == PwrStates::SWITCHING_POWER) {
pwrStateMachineWrapper(targetMode, targetSubmode);
}
} }
} }
void AcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) { void AcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) {
using namespace duallane; using namespace duallane;
pwrStateMachine.reset();
// If anything other than MODE_OFF is commanded, perform power state machine first // If anything other than MODE_OFF is commanded, perform power state machine first
if (mode != MODE_OFF) { if (mode != MODE_OFF) {
pwrStateMachine.reset();
// Cache the target modes, required by power state machine // Cache the target modes, required by power state machine
pwrStateMachine.start(mode, submode);
// Cache these for later after the power state machine has finished
targetMode = mode; targetMode = mode;
targetSubmode = submode; targetSubmode = submode;
state = PwrStates::SWITCHING_POWER;
// Perform power state machine first, then start mode transition. The power state machine will // Perform power state machine first, then start mode transition. The power state machine will
// start the transition after it has finished // start the transition after it has finished
pwrStateMachineWrapper(mode, submode); pwrStateMachineWrapper();
} else { } else {
// Command the devices to off first before switching off the power. The handleModeReached // Command the devices to off first before switching off the power. The handleModeReached
// custom implementation will take care of starting the power state machine. // custom implementation will take care of starting the power state machine.
@ -72,11 +65,6 @@ ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode)
using namespace duallane; using namespace duallane;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
refreshHelperModes(); refreshHelperModes();
result = pwrStateMachineWrapper(mode, submode);
if (result != RETURN_OK) {
return result;
}
if (state == PwrStates::MODE_COMMANDING) {
if (mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_ON) { if (mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_ON) {
result = handleNormalOrOnModeCmd(mode, submode); result = handleNormalOrOnModeCmd(mode, submode);
} else { } else {
@ -101,18 +89,17 @@ ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode)
} }
HybridIterator<ModeListEntry> tableIter(modeTable.begin(), modeTable.end()); HybridIterator<ModeListEntry> tableIter(modeTable.begin(), modeTable.end());
executeTable(tableIter); executeTable(tableIter);
}
return result; return result;
} }
ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) { ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
using namespace duallane; using namespace duallane;
refreshHelperModes(); refreshHelperModes();
if (state == PwrStates::SWITCHING_POWER) { // if (state == PwrStates::SWITCHING_POWER) {
// Wrong mode // // Wrong mode
sif::error << "Wrong mode, currently switching power" << std::endl; // sif::error << "Wrong mode, currently switching power" << std::endl;
return RETURN_OK; // return RETURN_OK;
} // }
if (wantedSubmode == A_SIDE) { if (wantedSubmode == A_SIDE) {
if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or
(helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != wantedMode) or (helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != wantedMode) or
@ -277,11 +264,10 @@ bool AcsBoardAssembly::isUseable(object_id_t object, Mode_t mode) {
void AcsBoardAssembly::handleModeReached() { void AcsBoardAssembly::handleModeReached() {
using namespace duallane; using namespace duallane;
if (targetMode == MODE_OFF) { if (targetMode == MODE_OFF) {
pwrStateMachine.reset(); pwrStateMachine.start(targetMode, targetSubmode);
state = PwrStates::SWITCHING_POWER;
// Now we can switch off the power. After that, the AssemblyBase::handleModeReached function // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function
// will be called // will be called
pwrStateMachineWrapper(targetMode, targetSubmode); pwrStateMachineWrapper();
} else { } else {
finishModeOp(); finishModeOp();
} }
@ -388,15 +374,15 @@ void AcsBoardAssembly::finishModeOp() {
dualModeErrorSwitch = true; dualModeErrorSwitch = true;
} }
ReturnValue_t AcsBoardAssembly::pwrStateMachineWrapper(Mode_t mode, Submode_t submode) { ReturnValue_t AcsBoardAssembly::pwrStateMachineWrapper() {
using namespace duallane; using namespace duallane;
OpCodes opCode = pwrStateMachine.powerStateMachine(mode, submode); OpCodes opCode = pwrStateMachine.powerStateMachine();
if (opCode == OpCodes::NONE) { if (opCode == OpCodes::NONE) {
return RETURN_OK; return RETURN_OK;
} else if (opCode == OpCodes::FINISH_OP) { } else if (opCode == OpCodes::FINISH_OP) {
finishModeOp(); finishModeOp();
} else if (opCode == OpCodes::START_TRANSITION) { } else if (opCode == OpCodes::START_TRANSITION) {
AssemblyBase::startTransition(mode, submode); AssemblyBase::startTransition(targetMode, targetSubmode);
} else if (opCode == OpCodes::TIMEOUT_OCCURED) { } else if (opCode == OpCodes::TIMEOUT_OCCURED) {
if (powerRetryCounter == 0) { if (powerRetryCounter == 0) {
powerRetryCounter++; powerRetryCounter++;

View File

@ -107,7 +107,7 @@ class AcsBoardAssembly : public AssemblyBase {
AcsBoardHelper helper; AcsBoardHelper helper;
GpioIF* gpioIF = nullptr; GpioIF* gpioIF = nullptr;
uint8_t powerRetryCounter = 0; uint8_t powerRetryCounter = 0;
duallane::PwrStates state = duallane::PwrStates::IDLE; // duallane::PwrStates state = duallane::PwrStates::IDLE;
duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE; duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE;
bool dualModeErrorSwitch = true; bool dualModeErrorSwitch = true;
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable; FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
@ -141,7 +141,7 @@ class AcsBoardAssembly : public AssemblyBase {
* @param mode * @param mode
* @param submode * @param submode
*/ */
ReturnValue_t pwrStateMachineWrapper(Mode_t mode, Submode_t submode); ReturnValue_t pwrStateMachineWrapper();
}; };
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */ #endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */

View File

@ -6,35 +6,49 @@
DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches switchA, DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches switchA,
pcduSwitches::Switches switchB, pcduSwitches::Switches switchB,
PowerSwitchIF* pwrSwitcher, PowerSwitchIF* pwrSwitcher,
duallane::PwrStates& state,
dur_millis_t checkTimeout) dur_millis_t checkTimeout)
: SWITCH_A(switchA), : SWITCH_A(switchA), SWITCH_B(switchB), pwrSwitcher(pwrSwitcher), checkTimeout(checkTimeout) {}
SWITCH_B(switchB),
state(state),
pwrSwitcher(pwrSwitcher),
checkTimeout(checkTimeout) {}
void DualLanePowerStateMachine::setCheckTimeout(dur_millis_t timeout) { void DualLanePowerStateMachine::setCheckTimeout(dur_millis_t timeout) {
checkTimeout.setTimeout(timeout); checkTimeout.setTimeout(timeout);
} }
duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Submode_t submode) { void DualLanePowerStateMachine::start(Mode_t mode, Submode_t submode) {
checkTimeout.resetTimer();
targetMode = mode;
targetSubmode = submode;
state = duallane::PwrStates::SWITCHING_POWER;
}
duallane::PwrStates DualLanePowerStateMachine::getState() const { return state; }
bool DualLanePowerStateMachine::active() {
if (state == duallane::PwrStates::IDLE or state == duallane::PwrStates::MODE_COMMANDING) {
return false;
}
return true;
}
duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
using namespace duallane; using namespace duallane;
ReturnValue_t switchStateA = RETURN_OK; ReturnValue_t switchStateA = RETURN_OK;
ReturnValue_t switchStateB = RETURN_OK; ReturnValue_t switchStateB = RETURN_OK;
if (state == PwrStates::IDLE or state == PwrStates::SWITCHING_POWER or if (state == PwrStates::IDLE or state == PwrStates::MODE_COMMANDING) {
state == PwrStates::CHECKING_POWER) { return duallane::OpCodes::NONE;
}
if (state == PwrStates::SWITCHING_POWER or state == PwrStates::CHECKING_POWER) {
switchStateA = pwrSwitcher->getSwitchState(SWITCH_A); switchStateA = pwrSwitcher->getSwitchState(SWITCH_A);
switchStateB = pwrSwitcher->getSwitchState(SWITCH_B); switchStateB = pwrSwitcher->getSwitchState(SWITCH_B);
} else { } else {
return OpCodes::NONE; return OpCodes::NONE;
} }
if (mode == HasModesIF::MODE_OFF) { if (targetMode == HasModesIF::MODE_OFF) {
if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_OFF) { if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_OFF) {
state = PwrStates::IDLE;
return OpCodes::FINISH_OP; return OpCodes::FINISH_OP;
} }
} else { } else {
switch (submode) { switch (targetSubmode) {
case (A_SIDE): { case (A_SIDE): {
if (switchStateA == PowerSwitchIF::SWITCH_ON and if (switchStateA == PowerSwitchIF::SWITCH_ON and
switchStateB == PowerSwitchIF::SWITCH_OFF) { switchStateB == PowerSwitchIF::SWITCH_OFF) {
@ -60,16 +74,16 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
} }
} }
if (state == PwrStates::SWITCHING_POWER) { if (state == PwrStates::SWITCHING_POWER) {
if (mode == HasModesIF::MODE_OFF) { if (targetMode == HasModesIF::MODE_OFF) {
if (switchStateA != PowerSwitchIF::SWITCH_OFF) { if (switchStateA != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_ON); pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_OFF);
} }
if (switchStateB != PowerSwitchIF::SWITCH_OFF) { if (switchStateB != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_OFF); pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_OFF);
} }
checkTimeout.resetTimer(); checkTimeout.resetTimer();
} else { } else {
switch (submode) { switch (targetSubmode) {
case (A_SIDE): { case (A_SIDE): {
if (switchStateA != PowerSwitchIF::SWITCH_ON) { if (switchStateA != PowerSwitchIF::SWITCH_ON) {
pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_ON); pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_ON);
@ -114,5 +128,7 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
void DualLanePowerStateMachine::reset() { void DualLanePowerStateMachine::reset() {
state = duallane::PwrStates::IDLE; state = duallane::PwrStates::IDLE;
targetMode = HasModesIF::MODE_OFF;
targetSubmode = 0;
checkTimeout.resetTimer(); checkTimeout.resetTimer();
} }

View File

@ -12,17 +12,21 @@ class PowerSwitchIF;
class DualLanePowerStateMachine : public HasReturnvaluesIF { class DualLanePowerStateMachine : public HasReturnvaluesIF {
public: public:
DualLanePowerStateMachine(pcduSwitches::Switches switchA, pcduSwitches::Switches switchB, DualLanePowerStateMachine(pcduSwitches::Switches switchA, pcduSwitches::Switches switchB,
PowerSwitchIF* pwrSwitcher, duallane::PwrStates& state, PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout = 5000);
dur_millis_t checkTimeout = 3000);
void setCheckTimeout(dur_millis_t timeout); void setCheckTimeout(dur_millis_t timeout);
void reset(); void reset();
duallane::OpCodes powerStateMachine(Mode_t mode, Submode_t submode); void start(Mode_t mode, Submode_t submode);
bool active();
duallane::PwrStates getState() const;
duallane::OpCodes powerStateMachine();
const pcduSwitches::Switches SWITCH_A; const pcduSwitches::Switches SWITCH_A;
const pcduSwitches::Switches SWITCH_B; const pcduSwitches::Switches SWITCH_B;
private: private:
duallane::PwrStates& state; duallane::PwrStates state = duallane::PwrStates::IDLE;
PowerSwitchIF* pwrSwitcher = nullptr; PowerSwitchIF* pwrSwitcher = nullptr;
Mode_t targetMode = HasModesIF::MODE_OFF;
Submode_t targetSubmode = 0;
Countdown checkTimeout; Countdown checkTimeout;
}; };

2
tmtc

@ -1 +1 @@
Subproject commit eb7fd71eaf9872281ee086e858028658863dd89d Subproject commit d64d443a99a911f946402e59b276566954b5b52b