SFCs in Action
Chart Flow
All charts start at their begin step. The begin step can define initial values for variables in the chart's scope. These initial values are defined as expressions.
Flow always moves downward out of chart elements, except for links, which can move flow in any direction.
When flow hits a step, that step is started. The step continues to execute until the transition beneath it becomes true. If there is no transition beneath a step, the step starts and is told to stop as soon as possible. In practice, this means that an action step's onStart and onStop scripts will be run, but no timer scripts.
Examples
Example 1
In this example, step S1 executes as soon as the chart starts, and continues executing until the transition beneath it becomes true. Once that transition becomes true, Step S1 is told to stop, which means it finishs executing any scripts that are currently running, and then it executes its onStop action (if any).
After S1 has stopped, step S2 starts. It is immediately told to stop, which means that if it has any timer actions, they will not run, but the start and stop actions will run.
After S2 is finished, the chart stops.
Example 2
In this example, step S1 executes as above, except that it has two transitions beneath it. This is how you do conditional logic in a chart. S1 runs until either of these transitions becomes true. When one transition becomes true, flow will follow that branch of of the chart. If both transitions are true, the transition on the left is chosen. Position is meaningful for charts - transition precedence goes from left to right.
Only one of S2 or S3 will run, but never both.
Example 3
In this example, S1 executes as above, but can execute multiple times. This is how you configure repeating logic in a chart. The two transitions determine whether this chart continues running (possibly indefinitely) or stops.
Example 4
In this example, steps S1 and S2 execute simultaneously. They both continue to run until the transitions beneath them become true.
Flow only moves past the parallel sync (the bottom of the parallel section) once both transitions become true. Step S3 then runs, and then the chart stops.
In this section ...