Transitions are where all of the excitement happens in an FSM.

Transitions occur when an event is sent to the FSM. The purposes of a transition is to move the FSM from the existing state(s) into a new state(s).

We refer to the set of active states as a StateOfMind. UML2 refer to this as a State Configuration but that is such a boring non-descriptive term we had to use something else.

Some transitions will result in the FSM not changing states. The transition attempt could be blocked by a guard condition or the transition simple ends up with the FSM ending in the same state it started with.

You trigger a transition by calling statemachine.applyEvent passing an Event.

The FSM will look at what state(s) it is in. The FSM will then look for a transition handler for the event in each of the current states.

There are a number of transition handlers:

If a matching transition is found its guard condition is checked. If the guard condition evaluates to false then the FSM searches for the next matching transition.

If the guard condition evaluates to true then the transition is triggered.

States can define multiple transitions for the same event with different guard conditions.

If no transition is triggered the FSM will then search the state's ancestors (from the current state(s) upwards) for a matching transition and apply the same rules.

If the FSM has active Concurrent Regions then the above process will be applied to the active state in each concurrent region and as such multiple state transitions may occur as the result of a single Event.

Ordering of Transitions

Ordering of transitions is critical to the correct operation of the FSM.

FSM2 queues all transitions into the state machine and won't allow the transition to be applied to the FSM until all previously queued transitions are completed.

Transitions are always processed in the order the are submitted (FIFO).

Nested Transitions

In some cases you may need to trigger a transition whilst in a callback from the FSM (e.g. onEnter, onExit or sideEffect in turn trigger a new transition). This is fine, the FSM will simply queue the transition and it will be applied once all previously queued transitions have completed.

Last updated