betfsm.TickingStateMachine
Bases: TickingState
A StateMachine that calls a callback function before entering a state and/or at each transition.
This statemachine is capable of working together with TickingState:
- will exit when TICKING outcome is given by one of the substates, but then if it is called again, it will have remembered the state that had the TICKING outcome and start from that state.
- if returning with any other outcome, will start next time from the start state.
__init__(name, outcomes)
TickintStatemachine is a statemachine that can maintain TickingStates.
| Parameters: |
|
|---|
accept(visitor)
accepts a visitor to go through all states of an hierarchy
add_state(state, transitions=None)
add_state(state,transitions) adds a state and associates transitions in this state-machine
with this state. By default to first state added will be the start state. This can be changed
using the method set_start_state.
| Parameters: |
|
|---|
Note
- The keys of the transitions Dict are outcomes. The values are targets.
- A target can be a state object or the name of a state.
- A target can also be an outcome that is listed in the outcomes of the state machine. In that case the state machine will exit with that outcome.
- A target can be another outcome that the statemachine will try to resolve. This is mostly useful for
default transitions (see
set_default_transitions). This redirection can even redirect TICKING (for advanced use). - a BeTFSM object can only be added as a child once. BeTFSM hierarchy is required to be a tree, not a more general graph.
reset()
Resets the state-machine. Ensures that the next call will start again from the starting state. Calls reset on all the states it contains.
set_default_transitions(transitions={})
Adds default transitions to each state added afterwards. The transitions
specified in add_state add to or overwrite these default transitions.
| Parameters: |
|
|---|
set_start_state(name)
Explicitly states the starting state. States are specified using their name
| Parameters: |
|
|---|