Stateflow    

For Loop Construct Example

This example shows the behavior of a for loop using a connective junction.

Initially the Stateflow diagram is asleep. State A is active. Event E_one occurs and awakens the Stateflow diagram. 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. There is a valid transition segment from state A to the connective junction. The transition segment condition action, i = 0, is executed and completed. Of the two transition segments leaving the connective junction, the transition segment that is a self-loop back to the connective junction is evaluated next for validity. That segment takes priority in evaluation because it has a condition specified, whereas the other segment is unlabeled.
  2. The condition [i < 10] is evaluated as true. The condition actions i++ and a call to func1 are executed and completed until the condition becomes false. A connective junction is not a final destination; thus the transition destination remains to be determined.
  3. The unconditional segment to state B is now valid. The complete transition from state A to state B is valid.
  4. State A exit actions (exitA()) execute and complete.
  5. State A is marked inactive.
  6. State B is marked active.
  7. State B entry actions (entB()) execute and complete.
  8. 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.


  Self-Loop Transition Example Flow Diagram Notation Example