Stateflow | ![]() ![]() |
Example: Event Broadcast State Action
This example shows the semantics of event broadcast state actions.
Initially the Stateflow diagram is asleep. Parallel substates A
.A1
.A1a
and A
.A2
.A2a
are 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 no valid transition.
A
executes and completes during
actions (durA()
).
A
.A1
is evaluated first. State A
.A1
executes and completes during
actions (durA1()
). State A
.A1
executes and completes the on
E_one
action and broadcasts event E_two
. during
and on
event_name actions are processed based on their order of appearance in the state label.
E_two
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_two
. There is no valid transition.
during
actions (durA())
.
A
.A1
. State A
.A1
executes and completes during
actions (durA1()
). State A
.A1
is evaluated
for valid transitions. There are no valid transitions as a result of E_two
within state A1
.
A
.A2
is evaluated. State A
.A2
executes and completes during
actions
(durA2()
). State A
.A2
checks for valid transitions. State A
.A2
has a valid
transition as a result of E_two
from state A
.A2
.A2a
to state A
.A2
.A2b
.
A
.A2
.A2a
exit
actions execute and complete (exitA2a()
).
A
.A2
.A2a
is marked inactive.
A
.A2
.A2b
is marked active.
A
.A2
.A2b
entry
actions execute and complete (entA2b()
). The
Stateflow diagram activity now looks like this
A
.A1
.A1a
executes and completes exit
actions (exitA1a
).
E_one
continues once the on
event broadcast of E_two
has been processed. State A
.A1
checks for any valid transitions as a result of event E_one
. There is a valid transition from state A
.A1
.A1a
to state A
.A1
.A1b
.
A
.A1
.A1a
is marked inactive.
A
.A1
.A1b
executes and completes entry
actions (entA1b()
).
A
.A1
.A1b
is marked active.
A
.A2
is evaluated next. State A
.A2
during
actions execute and complete (durA2()
). There are no valid transitions as a result of E_one
.
A
.A2
.A2b
, now active as a result of the processing of the on
event broadcast of E_two
, executes and completes during
actions (durA2b()
).
This sequence completes the execution of this Stateflow diagram associated with event E_one
and the on
event broadcast to a parallel state of event E_two
. The final Stateflow diagram activity looks like this.
Example: Event Broadcast Transition Action (Nested Event Broadcast)
This example shows the semantics of an event broadcast transition action that includes nested event broadcasts.
Start of event E_one Processing
Initially the Stateflow diagram is asleep. Parallel substates A
.A1
.A1a
and A
.A2
.A2a
are 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 no valid transition.
A
executes and completes during
actions (durA()
).
A
.A1
is evaluated first. State A
.A1
executes and completes during
actions (durA1()
).
A
.A1
checks for any valid transitions as a result of event E_one
. There is a valid transition from state A
.A1
.A1a
to state A
.A1
.A1b
.
A.A1.A1a
executes and completes exit
actions (exitA1a
).
A.A1.A1a
is marked inactive.
Event E_two Preempts E_one
E_two
is executed and completed.
A1a
to state A1b
(as a result of event E_one
) is
now preempted by the broadcast of event E_two
.
E_two
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_two
. There is no valid transition.
during
actions (durA()
).
A
.A1
. State A
.A1
executes and completes during
actions (durA1()
). State A
.A1
is evaluated
for valid transitions. There are no valid transitions as a result of E_two
within state A1
.
A
.A2
is evaluated. State A
.A2
executes and completes during
actions
(durA2()
). State A
.A2
checks for valid transitions. State A
.A2
has a valid
transition as a result of E_two
from state A
.A2
.A2a
to state A
.A2
.A2b
.
A
.A2
.A2a
exit
actions execute and complete (exitA2a()
).
A
.A2
.A2a
is marked inactive.
A
.A2
.A2b
is marked active.
A
.A2
.A2b
entry
actions execute and complete (entA2b()
).
Event E_two Processing Ends
The Stateflow diagram activity now looks like this.
A
.A1
.A1b
is marked active.
Event E_one Processing Resumes
A
.A1
.A1b
executes and completes entry actions (entA1b()
).
A
.A2
is evaluated next. State A
.A2
during actions execute and complete (durA2()
). There are no valid transitions as a result of E_one
.
A
.A2
.A2b
, now active as a result of the processing of the transition action event broadcast of E_two
, executes and completes during actions (durA2b()
).
This sequence completes the execution of this Stateflow diagram associated with event E_one
and the transition action event broadcast to a parallel state of event E_two
. The final Stateflow diagram activity now looks like this.
Example: Event Broadcast Condition Action
This example shows the semantics of condition action event broadcast in parallel (AND) states.
Initially the Stateflow diagram is asleep. Parallel substates A
.A1
.A1a
and A
.A2
.A2a
are 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 no valid transition.
A
executes and completes during
actions (durA()
).
A
.A1
is evaluated first. State A
.A1
executes and completes during
actions (durA1()
).
A
.A1
checks for any valid transitions as a result of event E_one
. There is a valid transition from state A
.A1
.A1a
to state A
.A1
.A1b
. There is also a valid condition action. The condition action event broadcast of E_two
is executed and completed. State A
.A1
.A1a
is still active.
E_two
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_two
. There is no valid transition.
during
actions (durA()
).
A
.A1
. State A
.A1
executes and completes during
actions (durA1()
). State A
.A1
is evaluated
for valid transitions. There are no valid transitions as a result of E_two
within state A1
.
A
.A2
is evaluated. State A
.A2
executes and completes during
actions
(durA2()
). State A
.A2
checks for valid transitions. State A
.A2
has a valid
transition as a result of E_two
from state A
.A2
.A2a
to state A
.A2
.A2b
.
A
.A2
.A2a
exit
actions execute and complete (exitA2a()
).
A
.A2
.A2a
is marked inactive.
A
.A2
.A2b
is marked active.
A
.A2
.A2b
entry
actions execute and complete (entA2b()
).
The Stateflow diagram activity now looks like this.
A
.A1
.A1a
executes and completes exit
actions (exitA1a
).
A
.A1
.A1a
is marked inactive.
A
.A1
.A1b
executes and completes entry
actions (entA1b()
).
A
.A1
.A1b
is marked active.
A
.A2
is evaluated next. State A
.A2
during
actions execute and complete (durA2()
). There are no valid transitions as a result of E_one
.
A
.A2
.A2b
, now active as a result of the processing of the condition action event broadcast of E_two
, executes and completes during
actions (durA2b()
).
This sequence completes the execution of this Stateflow diagram associated with event E_one
and the condition action event broadcast to a parallel state of event E_two
. The final Stateflow diagram activity now looks like this.
![]() | Event Actions | Directed Event Broadcasting | ![]() |