v1.10.0 #220
@ -53,9 +53,7 @@ void AcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) {
|
|||||||
using namespace duallane;
|
using namespace duallane;
|
||||||
// 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) {
|
||||||
if (state != PwrStates::IDLE) {
|
pwrStateMachine.reset();
|
||||||
state = PwrStates::IDLE;
|
|
||||||
}
|
|
||||||
// Cache the target modes, required by power state machine
|
// Cache the target modes, required by power state machine
|
||||||
targetMode = mode;
|
targetMode = mode;
|
||||||
targetSubmode = submode;
|
targetSubmode = submode;
|
||||||
@ -74,7 +72,10 @@ 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();
|
||||||
pwrStateMachineWrapper(mode, submode);
|
result = pwrStateMachineWrapper(mode, submode);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
if (state == PwrStates::MODE_COMMANDING) {
|
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);
|
||||||
@ -276,9 +277,7 @@ 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) {
|
||||||
if (state != PwrStates::IDLE) {
|
pwrStateMachine.reset();
|
||||||
state = PwrStates::IDLE;
|
|
||||||
}
|
|
||||||
state = PwrStates::SWITCHING_POWER;
|
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
|
||||||
@ -383,22 +382,35 @@ void AcsBoardAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry)
|
|||||||
void AcsBoardAssembly::finishModeOp() {
|
void AcsBoardAssembly::finishModeOp() {
|
||||||
using namespace duallane;
|
using namespace duallane;
|
||||||
AssemblyBase::handleModeReached();
|
AssemblyBase::handleModeReached();
|
||||||
state = PwrStates::IDLE;
|
pwrStateMachine.reset();
|
||||||
|
powerRetryCounter = 0;
|
||||||
tryingOtherSide = false;
|
tryingOtherSide = false;
|
||||||
dualModeErrorSwitch = true;
|
dualModeErrorSwitch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AcsBoardAssembly::pwrStateMachineWrapper(Mode_t mode, Submode_t submode) {
|
ReturnValue_t AcsBoardAssembly::pwrStateMachineWrapper(Mode_t mode, Submode_t submode) {
|
||||||
using namespace duallane;
|
using namespace duallane;
|
||||||
OpCodes opCode = pwrStateMachine.powerStateMachine(mode, submode);
|
OpCodes opCode = pwrStateMachine.powerStateMachine(mode, submode);
|
||||||
if (opCode == OpCodes::NONE) {
|
if (opCode == OpCodes::NONE) {
|
||||||
return;
|
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(mode, submode);
|
||||||
|
} else if (opCode == OpCodes::TIMEOUT_OCCURED) {
|
||||||
|
if (powerRetryCounter == 0) {
|
||||||
|
powerRetryCounter++;
|
||||||
|
pwrStateMachine.reset();
|
||||||
|
} else {
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
|
sif::warning << "Timeout occured in power state machine" << std::endl;
|
||||||
|
#endif
|
||||||
|
triggerEvent(POWER_STATE_MACHINE_TIMEOUT, 0, 0);
|
||||||
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t AcsBoardAssembly::initialize() {
|
ReturnValue_t AcsBoardAssembly::initialize() {
|
||||||
ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA);
|
ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA);
|
||||||
|
@ -78,6 +78,9 @@ class AcsBoardAssembly : public AssemblyBase {
|
|||||||
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
|
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
|
||||||
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
|
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
|
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
|
||||||
|
static constexpr Event POWER_STATE_MACHINE_TIMEOUT =
|
||||||
|
event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM);
|
||||||
|
|
||||||
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
|
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
|
||||||
|
|
||||||
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
||||||
@ -103,6 +106,7 @@ class AcsBoardAssembly : public AssemblyBase {
|
|||||||
bool tryingOtherSide = false;
|
bool tryingOtherSide = false;
|
||||||
AcsBoardHelper helper;
|
AcsBoardHelper helper;
|
||||||
GpioIF* gpioIF = nullptr;
|
GpioIF* gpioIF = nullptr;
|
||||||
|
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;
|
||||||
@ -137,7 +141,7 @@ class AcsBoardAssembly : public AssemblyBase {
|
|||||||
* @param mode
|
* @param mode
|
||||||
* @param submode
|
* @param submode
|
||||||
*/
|
*/
|
||||||
void pwrStateMachineWrapper(Mode_t mode, Submode_t submode);
|
ReturnValue_t pwrStateMachineWrapper(Mode_t mode, Submode_t submode);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */
|
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */
|
||||||
|
@ -6,8 +6,17 @@
|
|||||||
DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches switchA,
|
DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches switchA,
|
||||||
pcduSwitches::Switches switchB,
|
pcduSwitches::Switches switchB,
|
||||||
PowerSwitchIF* pwrSwitcher,
|
PowerSwitchIF* pwrSwitcher,
|
||||||
duallane::PwrStates& state)
|
duallane::PwrStates& state,
|
||||||
: SWITCH_A(switchA), SWITCH_B(switchB), state(state), pwrSwitcher(pwrSwitcher) {}
|
dur_millis_t checkTimeout)
|
||||||
|
: SWITCH_A(switchA),
|
||||||
|
SWITCH_B(switchB),
|
||||||
|
state(state),
|
||||||
|
pwrSwitcher(pwrSwitcher),
|
||||||
|
checkTimeout(checkTimeout) {}
|
||||||
|
|
||||||
|
void DualLanePowerStateMachine::setCheckTimeout(dur_millis_t timeout) {
|
||||||
|
checkTimeout.setTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Submode_t submode) {
|
duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Submode_t submode) {
|
||||||
using namespace duallane;
|
using namespace duallane;
|
||||||
@ -58,6 +67,7 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
|
|||||||
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();
|
||||||
} else {
|
} else {
|
||||||
switch (submode) {
|
switch (submode) {
|
||||||
case (A_SIDE): {
|
case (A_SIDE): {
|
||||||
@ -67,6 +77,7 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
|
|||||||
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();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (B_SIDE): {
|
case (B_SIDE): {
|
||||||
@ -76,6 +87,7 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
|
|||||||
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
||||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_OFF);
|
pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_OFF);
|
||||||
}
|
}
|
||||||
|
checkTimeout.resetTimer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (DUAL_MODE): {
|
case (DUAL_MODE): {
|
||||||
@ -85,6 +97,7 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
|
|||||||
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
||||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_ON);
|
pwrSwitcher->sendSwitchCommand(SWITCH_B, PowerSwitchIF::SWITCH_ON);
|
||||||
}
|
}
|
||||||
|
checkTimeout.resetTimer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +105,14 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine(Mode_t mode, Subm
|
|||||||
state = PwrStates::CHECKING_POWER;
|
state = PwrStates::CHECKING_POWER;
|
||||||
}
|
}
|
||||||
if (state == PwrStates::CHECKING_POWER) {
|
if (state == PwrStates::CHECKING_POWER) {
|
||||||
// TODO: Could check for a timeout (temporal or cycles) here and resend command
|
if (checkTimeout.hasTimedOut()) {
|
||||||
|
return OpCodes::TIMEOUT_OCCURED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return OpCodes::NONE;
|
return OpCodes::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DualLanePowerStateMachine::reset() {
|
||||||
|
state = duallane::PwrStates::IDLE;
|
||||||
|
checkTimeout.resetTimer();
|
||||||
|
}
|
||||||
|
@ -12,7 +12,10 @@ 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, duallane::PwrStates& state,
|
||||||
|
dur_millis_t checkTimeout = 3000);
|
||||||
|
void setCheckTimeout(dur_millis_t timeout);
|
||||||
|
void reset();
|
||||||
duallane::OpCodes powerStateMachine(Mode_t mode, Submode_t submode);
|
duallane::OpCodes powerStateMachine(Mode_t mode, Submode_t submode);
|
||||||
const pcduSwitches::Switches SWITCH_A;
|
const pcduSwitches::Switches SWITCH_A;
|
||||||
const pcduSwitches::Switches SWITCH_B;
|
const pcduSwitches::Switches SWITCH_B;
|
||||||
@ -20,6 +23,7 @@ class DualLanePowerStateMachine : public HasReturnvaluesIF {
|
|||||||
private:
|
private:
|
||||||
duallane::PwrStates& state;
|
duallane::PwrStates& state;
|
||||||
PowerSwitchIF* pwrSwitcher = nullptr;
|
PowerSwitchIF* pwrSwitcher = nullptr;
|
||||||
|
Countdown checkTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_SYSTEM_DUALLANEPOWERSTATEMACHINE_H_ */
|
#endif /* MISSION_SYSTEM_DUALLANEPOWERSTATEMACHINE_H_ */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
namespace duallane {
|
namespace duallane {
|
||||||
|
|
||||||
enum class PwrStates { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
|
enum class PwrStates { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
|
||||||
enum class OpCodes { NONE, FINISH_OP, START_TRANSITION };
|
enum class OpCodes { NONE, FINISH_OP, START_TRANSITION, TIMEOUT_OCCURED };
|
||||||
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
|
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
|
||||||
|
|
||||||
} // namespace duallane
|
} // namespace duallane
|
||||||
|
Loading…
Reference in New Issue
Block a user