Stateflow    

Execution Order Guidelines

Execution order of transitions originating from the same source is based on these guidelines. The guidelines appear in order of their precedence:

  1. Transitions are evaluated, based on hierarchy, in a top-down manner. In this example, when an event occurs and state A.A1 is active, the transition from state A.A1 to state B is valid and takes precedence over the transition from state A.A1 to state A.A2 based on the hierarchy.

  2. Transitions are evaluated based on their labels.
    1. Labels with events and conditions
    2. Labels with events
    3. Labels with conditions
    4. No label
  3. Equivalent transitions (based on their labels) are evaluated based on the geometry of the outgoing transitions. The geometry of junctions and states is considered separately.

Junctions

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. 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. A -> B

    Since the condition [C_one == 1] is false, this transition is not valid.

  1. A -> C

    Since the condition [C_two == 2] is false, this transition is not valid.

  1. A -> D

    Since the condition [C_three == 3] is true, this transition is valid and is taken.

  1. A -> E

    This transition, even though it too is valid, is not evaluated since the previous transition evaluated was valid.

States

Multiple outgoing transitions from states that are of equivalent label priority are evaluated in a clockwise progression starting at the upper, left corner of the 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. Given that, the outgoing transitions from the state are evaluated in this order:

  1. A -> B

    Since the condition [C_one == 1] is false, this transition is not valid.

  1. A -> C

    Since the condition [C_two == 2] is true, this transition is valid and is taken.

  1. A -> D

    This transition, even though it too is valid, is not evaluated since the previous transition evaluated was valid.


 Execution Order Parallel (AND) States