implement transitions
EIVE/eive-obsw/pipeline/head There was a failure building this commit Details

This commit is contained in:
Robin Müller 2024-04-16 17:40:13 +02:00
parent fac688d4c9
commit 85d0ffed0d
1 changed files with 12 additions and 1 deletions

View File

@ -53,6 +53,7 @@ void FreshMpsocHandler::performDeviceOperation(uint8_t opCode) {
void FreshMpsocHandler::performDefaultDeviceOperation() { void FreshMpsocHandler::performDefaultDeviceOperation() {
handleQueue(); handleQueue();
if (transitionActive) { if (transitionActive) {
// TODO: Timeout handling for transitions.
if (targetMode == MODE_ON or targetMode == MODE_NORMAL) { if (targetMode == MODE_ON or targetMode == MODE_NORMAL) {
handleTransitionToOn(); handleTransitionToOn();
} else if (targetMode == MODE_OFF) { } else if (targetMode == MODE_OFF) {
@ -276,7 +277,15 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
* @overload * @overload
* @param submode * @param submode
*/ */
void FreshMpsocHandler::startTransition(Mode_t newMode, Submode_t submode) {} void FreshMpsocHandler::startTransition(Mode_t newMode, Submode_t submode) {
// OFF commands are always accepted. Otherwise, ignore transition requests.
if (transitionActive && newMode != HasModesIF::MODE_OFF) {
return;
}
targetMode = newMode;
targetSubmode = submode;
transitionActive = true;
}
ReturnValue_t FreshMpsocHandler::performDeviceOperationPreQueueHandling(uint8_t opCode) { ReturnValue_t FreshMpsocHandler::performDeviceOperationPreQueueHandling(uint8_t opCode) {
return returnvalue::OK; return returnvalue::OK;
@ -293,6 +302,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
} }
if (startupState == StartupState::DONE) { if (startupState == StartupState::DONE) {
setMode(MODE_ON); setMode(MODE_ON);
transitionActive = false;
hkReport.setReportingEnabled(true); hkReport.setReportingEnabled(true);
powerState = PowerState::IDLE; powerState = PowerState::IDLE;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
@ -303,6 +313,7 @@ void FreshMpsocHandler::handleTransitionToOff() {
if (handleHwShutdown()) { if (handleHwShutdown()) {
hkReport.setReportingEnabled(false); hkReport.setReportingEnabled(false);
setMode(MODE_OFF); setMode(MODE_OFF);
transitionActive = false;
// commandIsPending = false; // commandIsPending = false;
// sequenceCount = 0; // sequenceCount = 0;
powerState = PowerState::IDLE; powerState = PowerState::IDLE;