Stateflow | ![]() ![]() |
Example: Actions Specified as Condition Actions
This example shows the semantics of a simple condition action in a multiple segment transition.
Initially the Stateflow diagram is asleep. State A
is active. Event E_one
occurs and awakens the Stateflow diagram. Conditions C_one
and C_two
are false. Event E_one
is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:
E_one
. A valid transition segment from state A
to a connective junction is detected. The condition action, A_one
, is detected on the valid transition segment and is immediately executed and completed. State A
is still active.
A
remains active. State A
during action executes and completes (durA()
).
This sequence completes the execution of the Stateflow diagram associated with event E_one
when state A
was active.
Example: Actions Specified as Condition and Transition Actions
This example shows the semantics of a simple condition and transition action specified on a transition from one exclusive (OR) state to another.
Initially the Stateflow diagram is asleep. State A
is 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:
E_one
. A valid transition from state A
to state B
is detected. The condition, C_one
is true. The condition action, A_one
, is detected on the valid transition and is immediately executed and completed. State A
is still active.
A
exit actions execute and complete (ExitA()
).
A
is marked inactive.
A_two
, is executed and completed.
B
is marked active.
B
entry actions execute and complete (entB()
).
This sequence completes the execution of the Stateflow diagram associated with event E_one
when state A
was active.
Example: Using Condition Actions in For Loop Construct
Condition actions and connective junctions are used to design a for
loop construct. This example shows the use of a condition action and connective junction to create a for
loop construct.
See Example: For Loop Construct to see the semantics of this example.
Example: Using Condition Actions to Broadcast Events to Parallel (AND) States
Condition actions can be used to broadcast events immediately to parallel (AND) states. This example shows this use.
See Example: Event Broadcast Condition Action to see the semantics of this example.
Example: Cyclic Behavior to Avoid When Using Condition Actions
This example shows a notation to avoid when using event broadcasts as condition actions because the semantics result in cyclic behavior.
Initially the Stateflow diagram is asleep. State On
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
. A valid transition from state On
to state Off
is detected. A condition action, broadcast of event E_one
, is detected on the valid transition and is immediately executed. State On
is still active.
The broadcast of event E_one
awakens the Stateflow diagram a second time.
The Stateflow diagram root checks to see if there is a valid transition as a
result of E_one
. The transition from state On
to state Off
is still valid. The
condition action, broadcast of event E_one
, is immediately executed again.
This sequence never completes when event E_one
is broadcast and state On
is active.
![]() | Transitions to and from Exclusive (OR) States | Default Transitions | ![]() |