Executing a Transition

About Transitions

Transitions play a large role in defining the animation or execution of a system. If your chart has exclusive (OR) states, its execution begins with the default transitions that point to the first active states in your chart.

Transitions have sources and destinations; thus, any actions associated with the sources or destinations are related to the transition that joins them. The type of the source and destination is equally important to define the semantics.

Transition Flow Graph Types

Before executing transitions for an active state or chart, Stateflow software groups transitions by the following types:

Each set of flow graphs includes other transition segments connected to a qualifying transition segment through junctions and transitions. Consider the following example:

In this example, state A has both an inner and a default transition that connect to a junction with outgoing transitions to states A.A1 and A.A2. If state A is active, its set of inner flow graphs includes:

In addition, state A's set of default flow graphs includes:

In this case, the two outgoing transition segments from the junction become members of more than one flow graph type.

Executing a Set of Flow Graphs

Each flow graph group is executed in the order of group priority until a valid transition is found. The default transitions group is executed first, followed by the outer transitions group and then the inner transitions group. Each flow graph group is executed with the following procedure.

  1. Order the group's transition segments for the active state.

    An active state can have several possible outgoing transitions. The chart orders these transitions before checking them for validity. See Evaluation Order for Outgoing Transitions.

  2. Select the next transition segment in the set of ordered transitions.

  3. Test the transition segment for validity.

  4. If the segment is invalid, go to step 2.

  5. If the destination of the transition segment is a state, do the following:

    1. No more transition segments are tested and a transition path is formed by including the transition segment from each preceding junction back to the starting transition.

    2. The states that are the immediate children of the parent of the transition path are exited (see Exiting an Active State).

    3. The transition action for the final transition segment of the full transition path is executed.

    4. The destination state is entered (see Entering a State).

  6. If the destination is a junction with no outgoing transition segments, do the following:

    1. Testing stops without any states being exited or entered.

  7. If the destination is a junction with outgoing transition segments, repeat step 1 for the set of outgoing segments.

  8. After testing all outgoing transition segments at a junction, take the following actions:

    1. Back up the incoming transition segment that brought you to the junction

    2. Continue at step 2, starting with the next transition segment after the backup segment

    The set of flow graphs completes execution when all starting transitions have been tested.

  


 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS