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:
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.
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.
B
is now valid. The complete transition from state A
to state B
is valid.
A
exit actions (exitA()
) execute and complete.
A
is marked inactive.
B
is marked active.
B
entry actions (entB()
) execute and complete.
This sequence completes the execution of this Stateflow diagram associated with event E_one
.
![]() | Self-Loop Transition Example | Flow Diagram Notation Example | ![]() |