mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-09-29 02:57:33 +00:00
Added changes for potential statemachine rework
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user