Inner Transition Examples

Processing Events with an Inner Transition in an Exclusive (OR) State Example

This example shows what happens when processing three events using an inner transition in an exclusive (OR) state.

Processing One Event in an Exclusive (OR) State

This example shows the behavior of an inner transition.

Initially, the Stateflow chart is asleep. State A is active. Event E_one occurs and awakens the chart. Condition [C_one] is false. Event E_one is processed from the root of the chart down through the hierarchy of the chart:

  1. The Stateflow chart root checks to see if there is a valid transition as a result of E_one. A potentially valid transition from state A to state B is detected. However, the transition is not valid, because [C_one] is false.

  2. State A during actions (durA()) execute and complete.

  3. State A checks its children for a valid transition and detects a valid inner transition.

  4. State A remains active. The inner transition action A_two is executed and completed. Because it is an inner transition, state A's exit and entry actions are not executed.

  5. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_one.

Processing a Second Event in an Exclusive (OR) State

Using the previous example, this example shows what happens when a second event E_one occurs.

Initially, the Stateflow chart is asleep. State A is still active. Event E_one occurs and awakens the chart. Condition [C_one] is true. Event E_one is processed from the root of the chart down through the hierarchy of the chart with the following steps:

  1. The Stateflow chart root checks to see if there is a valid transition as a result of E_one.

    The transition from state A to state B is now valid because [C_one] is true.

  2. State A exit actions (exitA()) execute and complete.

  3. State A is marked inactive.

  4. The transition action A_one is executed and completed.

  5. State B is marked active.

  6. State B entry actions (entB()) execute and complete.

  7. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_one.

Processing a Third Event in an Exclusive (OR) State

Using the previous example, this example shows what happens when a third event, E_two, occurs.

Initially, the Stateflow chart is asleep. State B is now active. Event E_two occurs and awakens the chart. Condition [C_two] is false. Event E_two is processed from the root of the chart down through the hierarchy of the chart:

  1. The Stateflow chart root checks to see if there is a valid transition as a result of E_two.

    A potentially valid transition from state B to state A is detected. The transition is not valid because [C_two] is false. However, active state B has a valid self-loop transition.

  2. State B exit actions (exitB()) execute and complete.

  3. State B is marked inactive.

  4. The self-loop transition action, A_four, executes and completes.

  5. State B is marked active.

  6. State B entry actions (entB()) execute and complete.

  7. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_two. This example shows the difference in behavior between inner and self-loop transitions.

Processing Events with an Inner Transition to a Connective Junction Example

This example shows the behavior of handling repeated events using an inner transition to a connective junction.

Processing the First Event with an Inner Transition to a Connective Junction

This example shows the behavior of an inner transition to a connective junction for the first event. The chart uses implicit ordering of outgoing transitions (see Implicit Ordering of Outgoing Transitions).

Initially, the Stateflow chart is asleep. State A1 is active. Event E_one occurs and awakens the chart. Condition [C_two] is true. Event E_one is processed from the root of the chart down through the hierarchy of the chart:

  1. The Stateflow chart root checks to see if there is a valid transition at the root level as a result of E_one. There is no valid transition.

  2. State A during actions (durA()) execute and complete.

  3. State A checks itself for valid transitions and detects that there is a valid inner transition to a connective junction.

    The conditions are evaluated to determine whether one of the transitions is valid. Because implicit ordering applies, the segments labeled with a condition are evaluated before the unlabeled segment. The evaluation starts from a 12 o'clock position on the junction and progresses in a clockwise manner. Because [C_two] is true, the inner transition to the junction and then to state A.A2 is valid.

  4. State A.A1 exit actions (exitA1()) execute and complete.

  5. State A.A1 is marked inactive.

  6. State A.A2 is marked active.

  7. State A.A2 entry actions (entA2()) execute and complete.

  8. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_one when condition C_two is true.

Processing a Second Event with an Inner Transition to a Connective Junction

Continuing the previous example, this example shows the behavior of an inner transition to a junction when a second event E_one occurs. The chart uses implicit ordering of outgoing transitions (see Implicit Ordering of Outgoing Transitions).

Initially, the Stateflow chart is asleep. State A2 is active. Event E_one occurs and awakens the chart. Neither [C_one] nor [C_two] is true. Event E_one is processed from the root of the chart down through the hierarchy of the chart:

  1. The Stateflow chart root checks to see if there is a valid transition at the root level as a result of E_one. There is no valid transition.

  2. State A during actions (durA()) execute and complete.

  3. State A checks itself for valid transitions and detects a valid inner transition to a connective junction.

    The conditions are evaluated to determine whether one of the transitions is valid. Because implicit ordering applies, the segments labeled with a condition are evaluated before the unlabeled segment. The evaluation starts from a 12 o'clock position on the junction and progresses in a clockwise manner. Because neither [C_one] nor [C_two] is true, the unlabeled transition segment is evaluated and determined to be valid. The full transition from the inner transition to state A.A3 is valid.

  4. State A.A2 exit actions (exitA2()) execute and complete.

  5. State A.A2 is marked inactive.

  6. State A.A3 is marked active.

  7. State A.A3 entry actions (entA3()) execute and complete.

  8. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_one when neither [C_one] nor [C_two] is true.

Inner Transition to a History Junction Example

This example shows the behavior of an inner transition to a history junction.

Initially, the Stateflow chart is asleep. State A.A1 is active. There is history information because superstate A is active. Event E_one occurs and awakens the chart. Event E_one is processed from the root of the chart down through the hierarchy of the chart:

  1. The Stateflow chart root checks to see if there is a valid transition as a result of E_one. There is no valid transition.

  2. State A during actions execute and complete.

  3. State A checks itself for valid transitions and detects that there is a valid inner transition to a history junction. According to the behavior of history junctions, the last active state, A.A1, is the destination state.

  4. State A.A1 exit actions execute and complete.

  5. State A.A1 is marked inactive.

  6. State A.A1 is marked active.

  7. State A.A1 entry actions execute and complete.

  8. The chart goes back to sleep.

This sequence completes the execution of this Stateflow chart associated with event E_one when there is an inner transition to a history junction and state A.A1 is active.

  


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