Stateflow    

Flow Diagram Notation Example

This example shows the behavior of a Stateflow diagram that uses flow notation.

Initially the Stateflow diagram is asleep. State A.A1 is active. The condition [C_one()] is initially true. 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 no valid transition.
  2. State A checks itself for valid transitions and detects a valid inner transition to a connective junction.
  3. The next possible segments of the transition are evaluated. There is only one outgoing transition and it has a condition action defined. The condition action is executed and completed.
  4. The next possible segments are evaluated. There are two outgoing transitions; one is a conditional self-loop transition and the other is an unconditional transition segment. The conditional transition segment takes precedence. The condition [C_one()] is tested and is true; the self-loop transition is taken. Since a final transition destination has not been reached, this self-loop continues until [C_one()] is false.
  1. Assume that after five iterations [C_one()] is false.

  1. The next possible transition segment (to the next connective junction) is evaluated. It is an unconditional transition segment with a condition action. The transition segment is taken and the condition action, {d=my_func()}, is executed and completed. The returned value of d is 84.
  2. The next possible transition segment is evaluated. There are three possible outgoing transition segments to consider. Two are conditional; one is unconditional. The segment labeled with the condition [d<100] is evaluated first based on the geometry of the two outgoing conditional transition segments. Because the return value of d is 84, the condition [d<100] is true and this transition (to the destination state A.A1) is valid.
  3. State A.A1 exit actions (exitA1()) execute and complete.
  4. State A.A1 is marked inactive.
  5. State A.A1 is marked active.
  6. State A.A1 entry actions (entA1()) execute and complete.
  7. 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.


  For Loop Construct Example Transitions from a Common Source to Multiple Destinations Example