Stateflow    

Backtracking Behavior in Flow Graphs Example

This example shows the behavior of transitions with junctions that force back-tracking behavior in flow graphs.

Initially, state A is active and conditions c1, c2, and c3 are true:

  1. The Stateflow diagram root checks to see if there is a valid transition from state A.
  1. There is a valid transition segment marked with the condition c1 from state A to a connective junction.

  1. Condition c1 is true, therefore action a1 is executed.
  2. Condition c3 is true, therefore action a3 is executed.
  3. Condition c4 is not true, therefore control flow is back-tracked to state A.
  4. The Stateflow diagram root checks to see if there is another valid transition from state A.
  1. There is a valid transition segment marked with the condition c2 from state A to a connective junction.

  1. Condition c2 is true, therefore action a2 is executed.
  2. Condition c3 is true, therefore action a3 is executed.
  3. Condition c4 is not true, therefore control flow is back-tracked to state A.
  4. The Stateflow chart goes to sleep.

The preceding example shows the unanticipated behavior of executing both actions a1 and a2 and executing action a3 twice. To resolve this problem, consider the following.

In this example, the previous example is amended with two terminating junctions that allow flow to terminate if either c3 or c4 is not true. This leaves state A active without taking any unnecessary actions.


  Transitions from a Source to a Destination Based on a Common Event Example Event Actions in a Superstate Example