Define a state machine.
More...
#include <state_machine.h>
|
|
| StateMachine (const State s) |
| | Construct a state machine from the first given state.
|
| |
| | StateMachine (const State s, const uint32_t timeout, const State stateOnTimeout) |
| | Construct a state machine from the first given state, with a timeout to another.
|
| |
|
void | run () |
| | timeout check, and such, call it often
|
| |
| bool | set_state (const State s, bool forceUpdate=false) |
| | Set the machine state.
|
| |
| bool | set_state (const State s, const uint32_t timeout, const State stateOnTimeout) |
| | set the new current state, with a timeout
|
| |
|
void | update_timeout (const uint32_t timeout) |
| | Update the current state timeout if a timeout is active.
|
| |
|
bool | state_just_changed () |
| | Return true if the current state just changed. Resetted on read.
|
| |
|
bool | state_changed_with_timeout () |
| | return true if this state was reached with a timeout
|
| |
|
State | get_state () const |
| | Return the actual state.
|
| |
|
State | get_last_state () const |
| | Return the state before this one.
|
| |
|
void | skip_timeout () |
| | use this in a state with a timeout set to skip to the next state directly
|
| |
|
uint32_t | get_state_raised_time () const |
| | Return the time at which this state was raised.
|
| |
template<typename State>
class lampda::utils::StateMachine< State >
Define a state machine.
◆ StateMachine()
template<typename State >
Construct a state machine from the first given state, with a timeout to another.
- Parameters
-
| [in] | s | The initial state |
| [in] | timeout | The timeout after which we switch to the fallback state |
| [in] | stateOnTimeout | Falback state, reached on timeout |
◆ set_state() [1/2]
template<typename State >
Set the machine state.
- Parameters
-
| [in] | s | The new state to set |
| [in] | forceUpdate | Force the state update, even if the state is already active |
- Returns
- True if the state was updated
◆ set_state() [2/2]
template<typename State >
set the new current state, with a timeout
- Parameters
-
| [in] | s | the new state |
| [in] | timeout | The time out delay after which the state will switch automatically to stateOnTimeout |
| [in] | stateOnTimeout | State to reach after the timeout |
- Returns
- true is the state changed
The documentation for this class was generated from the following file: