Stateflow    

Ordering Single Source Transitions

Transitions from a single source are ordered for testing according to the following three sorting guidelines, which appear in order of their precedence (first step is highest priority):

  1. Endpoint Hierarchy -- Transitions whose end points are attached to higher hierarchical levels are placed first in testing order. See the topic Ordering by Hierarchy.
  2. Label -- Transitions are ordered for testing according to the types of action language present in their labels. See Ordering by Label.
  3. Angular Surface Position of Transition Source -- Transitions are ordered for testing based on the angular position of the transition source on the surface of the originating object. See Ordering by Angular Surface Position of Source.

Ordering by Hierarchy

Transitions are evaluated in a top-down manner based on hierarchy. In the following example, an event occurs while state A1 is active.

Because state B is a sibling of state A and at a higher hierarchical level than state A2, a sibling of A1, the transition from state A1 to state B takes precedence over the transition from state A1 to state A2.

Ordering by Label

Transitions of equal endpoint hierarchical level are evaluated based on their labels, in the following order of precedence:

  1. Labels with events and conditions
  2. Labels with events
  3. Labels with conditions
  4. No label

The following example demonstrates ordering of single source transitions by the angular surface position of the source.

Ordering by Angular Surface Position of Source

Equivalent transitions (based on their labels and the hierarchy of their source and endpoints) are ordered based on the angular position on the surface of the source object for the outgoing transitions.

Multiple outgoing transitions from states that are of equivalent label and source and end point hierarchy priority are evaluated in a clockwise progression starting at the upper left corner of the source state.

In this example, the transitions are of equivalent label priority. The conditions [C_two == 2] and [C_three == 3] are both true and [C_one = = 1] is false. Also, the hierarchical level of the endpoint of each transition is the same because all the states in the example are siblings.

The outgoing transitions from state A in the preceding diagram are evaluated in the following order:

  1. The angular position of the source point for the transition from state A to state B is 12 o'clock.
  1. Since the condition [C_one == 1] is false, this transition is not valid.

  1. The angular position of the source point for the transition from state A to state C is 2 o'clock.
  1. Since the condition [C_two == 2] is true, this transition is valid and is taken.

The angular position of the source point for the transition from state A to state D is 6 o'clock. This transition, even though it is valid, is not evaluated since the previous transition was taken.

Multiple outgoing transitions from junctions that are of equivalent label priority are evaluated in a clockwise progression starting from a twelve o'clock position on the junction.

In this example, the transitions are of equivalent label priority. Also, the conditions [C_three == 3]and [C_four == 4] are both true. Given that, the outgoing transitions from the junction are evaluated in this order:

  1. The transition to state B is evaluated. Since the condition [C_one == 1] is false, this transition is not valid.
  2. The transition to state C is evaluated. Since the condition [C_two == 2] is false, this transition is not valid.
  3. The transition to state D is evaluated. Since the condition [C_three == 3] is true, this transition is valid and is taken.
  1. Since the transition to D is taken, the transition to state E is not evaluated.


  Executing a Set of Flow Graphs Executing a State