| Stateflow User's Guide | ![]() |
Explicit Order Mode
Implicit ordering rules are complex and hard to master. Additionally, when you modify a diagram for cosmetic purposes, rearranging transitions may inadvertently change execution. This is why you have an option to switch from implicit ordering of transitions to a user-defined, or explicit, ordering. In this mode, you control the order in which transitions are tested for execution.
| Note You can reorder transitions only within their type (inner, outer, or default). For more information, see Transition Flow Graph Types. |
To control the order of transitions, you have to perform the following steps:
When you switch to explicit transition ordering, Stateflow stops evaluating the implicit rules. All the existing transitions in a diagram retain their current order numbers until you explicitly change them. All the newly created transitions for a source are automatically numbered in the order you create them, starting with the next available number for the source.
You can change the order of outgoing transitions for a source by explicitly renumbering them. When you change a transition number, Stateflow automatically renumbers the other outgoing transitions for the source by preserving their relative order. This is similar to taking a book out of a stack and then putting it back in a different place: the order of the other books is unchanged, and the books are renumbered accordingly. This behavior is consistent with the automatic renumbering rules for the Simulink ports.
For example, if you have a source with five outgoing transitions, as shown below, changing transition 4 to 2 results in the following automatic renumbering.
Automatic Renumbering of Transitions During Explicit Reordering
Switching to Explicit Order Mode
You switch to explicit ordering of transitions by setting your chart property preferences.
Now you can change the transition execution order for any source in the chart.
Switching between modes. If you switch back to implicit order mode after having explicitly reordered the transitions, the transition order is reset to follow the implicit rules.
Similarly, if you eventually change back to explicit order mode, without making any changes to the diagram, Stateflow restores the previous explicit transition order. Whenever you switch from one transition ordering mode to another, Stateflow displays the warnings about the changes in transition numbers in the diagnostic viewer.
Changing the Transition Order
You change the order of transitions originating from a source by explicitly renumbering them.
| Note If you select Execution Order while in implicit order mode, the only option available is Enable `User specified execution order' for this chart. This opens the properties dialog for the chart, to let you switch to explicit order mode, as described in Switching to Explicit Order Mode. |
Another way to access the transition order number is through its properties:
| Implicit Order Mode | Entering, Executing, and Exiting a State | ![]() |
© 1994-2005 The MathWorks, Inc.