/* * printable.cpp * * Created on: Aug 30, 2023 * Author: Dario */ #include #include #include #include #include #include #include #include namespace sta { namespace tacos { void onStatemachineInit() { Statemachine::instance()->setStateFunction([](uint16_t state) -> uint16_t { // ###### Implement your state transition function here! ###### /** * This function should return some state within 0 and STA_TACOS_NUM_STATES (specified in the config.hpp). * Return the same state as given as the argument for no state transition. Make sure, that this function is not * computationally expensive. */ return state; }); Statemachine::instance()->setTimerFunction([](uint16_t state, uint16_t lastState, uint32_t event) { // ###### Set the failsafe and lockout timers here ###### /** * This function is called after a state transition from lastState to state. Event corresponds to EventFlag enum in the Statemachine * and encode how the state change happened. * * Setting a timer here is fully optional and depends on your system's specifications. */ uint32_t someFailsafeMillis = 42; uint16_t someNextState = STA_TACOS_INITIAL_STATE; uint32_t someLockoutMillis = 21; // Start the failsafe timer to force a state transition to someNextState after someFailsafeMillis milliseconds. Statemachine::instance()->setFailsafeTimer(someFailsafeMillis, someNextState); // Start the lockout timer to block a state transition for the first someLockoutMillis milliseconds. Statemachine::instance()->setLockoutTimer(someLockoutMillis); }); } void onManagerInit() { // ###### Register different threads for different states here. ###### // The dummy task runs for state 0. Manager::instance()->registerThread(std::make_shared("Dummy"), {0}); } } // namespace tacos } // namespace sta