| Using Stateflow | Search  Help Desk |
Condition Actions
Example: Actions Specified as Condition Actions
This example shows the semantics of a simple condition action in a multiple segment transition.
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()).
.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.
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()).
.E_one when state A was active.
Example: Using Condition Actions in For Loop Construct
Condition actions and connective junctions are used to design afor loop construct. This example shows the use of a condition action and connective junction to create a for loop construct.
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.
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.
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.
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.
.E_one is broadcast and state On is active.