Added changes for potential statemachine rework

This commit is contained in:
dario
2023-11-07 12:37:53 +01:00
committed by carlwachter
parent 2205ff7446
commit 098ef140a6
5 changed files with 82 additions and 118 deletions

View File

@@ -24,38 +24,6 @@ namespace sta
{
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);
});
}