Stateflow    

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 diagram is asleep. State A is active. Event E_one occurs and awakens the Stateflow diagram. Condition [C_one] is false. Event E_one is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:

  1. The Stateflow diagram 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 Stateflow diagram goes back to sleep, waiting to be awakened by another event.

This sequence completes the execution of this Stateflow diagram 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 diagram is asleep. State A is still active. Event E_one occurs and awakens the Stateflow diagram. Condition [C_one] is true. Event E_one is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram with the following steps:

  1. The Stateflow diagram root checks to see if there is a valid transition as a result of E_one.
  1. The transition from state A to state B is now valid because [C_one] is true.

  1. State A exit actions (exitA()) execute and complete.
  2. State A is marked inactive.
  3. The transition action A_one is executed and completed.
  4. State B is marked active.
  5. State B entry actions (entB()) execute and complete.
  6. The Stateflow diagram goes back to sleep, waiting to be awakened by another event.

This sequence completes the execution of this Stateflow diagram 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 diagram is asleep. State B is now active. Event E_two occurs and awakens the Stateflow diagram. Condition [C_two] is false. Event E_two is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:

  1. The Stateflow diagram root checks to see if there is a valid transition as a result of E_two.
  1. 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.

  1. State B exit actions (exitB()) execute and complete.
  2. State B is marked inactive.
  3. The self-loop transition action, A_four, executes and completes.
  4. State B is marked active.
  5. State B entry actions (entB()) execute and complete.
  6. The Stateflow diagram goes back to sleep, waiting to be awakened by another event.

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


  Inner Transition Examples Processing Events with an Inner Transition to a Connective Junction Example