diff --git a/Libs/rtos2-utils b/Libs/rtos2-utils index 0e96b2e..c609dc8 160000 --- a/Libs/rtos2-utils +++ b/Libs/rtos2-utils @@ -1 +1 @@ -Subproject commit 0e96b2ec29fde1e56e12fc9f0dceb80012e0caf3 +Subproject commit c609dc81cc70327948aa8173c9d6ad804ae7a642 diff --git a/Tacos/src/manager.cpp b/Tacos/src/manager.cpp index 2b511ef..468c5fb 100644 --- a/Tacos/src/manager.cpp +++ b/Tacos/src/manager.cpp @@ -80,7 +80,7 @@ namespace sta void Manager::func() { - Statemachine::stateChangeEvent.wait(Statemachine::EventFlags::ALL, osWaitForever); + Statemachine::stateChangeEvent.wait(EventFlags::ALL, osWaitForever); HeapStats_t stats; vPortGetHeapStats(&stats); diff --git a/Tacos/src/statemachine.cpp b/Tacos/src/statemachine.cpp index aade590..a3b0227 100644 --- a/Tacos/src/statemachine.cpp +++ b/Tacos/src/statemachine.cpp @@ -17,11 +17,8 @@ namespace sta Statemachine::Statemachine() : TacosThread{"Statemachine", STA_TACOS_STATEMACHINE_PRIORITY}, currentState_{STA_TACOS_INITIAL_STATE}, - failsafeState_{STA_TACOS_INITIAL_STATE}, lockoutTimer_{[](void *){}, nullptr}, failsafeTimer_{[](void *){}, nullptr}, - transitionFunc_{[](uint16_t) -> uint16_t { return Statemachine::instance()->getCurrentState(); }}, - timerFunc_{[](uint16_t, uint16_t, uint16_t) {}}, queue_{STA_TACOS_STATEMACHINE_QUEUE_LENGTH} { STA_ASSERT(STA_TACOS_INITIAL_STATE < STA_TACOS_NUM_STATES); @@ -29,7 +26,7 @@ namespace sta void Statemachine::init() { - timerFunc_(0, 0, EventFlags::STARTUP); + } void Statemachine::func() @@ -55,18 +52,10 @@ namespace sta } // Start the lockout timer if requested. - if (transition.lockout != NULL) + if (transition.lockout != 0) { setLockoutTimer(transition.lockout); } - - // Start the failsafe timer if requested. - if (transition.failsafe != NULL) - { - std::tie(millis, state) = transition.failsafe; - - setFailsafeTimer(millis, state); - } } } @@ -89,12 +78,12 @@ namespace sta void Statemachine::requestTimedStateTransition(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout /* = 0 */) { - STA_ASSERT(nextState < STA_TACOS_NUM_STATES); + STA_ASSERT(to < STA_TACOS_NUM_STATES); STA_ASSERT(!failsafeTimer_.isRunning()); failsafeTimer_.setCallback([from, to, lockout](void* arg) { - Statemachine::requestStateTransition(from, to, lockout); - }, &failsafeState_); + Statemachine::instance()->requestStateTransition(from, to, lockout); + }, NULL); failsafeTimer_.start(millis); }