This example shows the behavior of event broadcast actions in parallel states. The chart uses implicit ordering of parallel states (see Implicit Ordering of Parallel States).
Initially, the chart is asleep. Parallel substates A.A1.A1a
and
A.A2.A2a
are active. Event E_one
occurs
and awakens the chart, which processes the event from the root down through the
hierarchy:
The chart root checks to see if there is a valid
transition at the root level as a result of E_one
. No
valid transition exists.
State A
during
actions (durA()
) execute and
complete.
The children of state A
are
parallel (AND) states. Because implicit ordering applies, the states are
evaluated and executed from left to right and top to bottom. State
A.A1
is evaluated first. State
A.A1
during
actions (durA1()
) execute and
complete. State A.A1
executes and completes the
on
E_one
action and broadcasts event
E_two
. The during
and
on
event_name
actions are processed based on their
order of appearance in the state label:
The broadcast of event E_two
awakens the chart
a second time. The chart root checks to see if there is a valid
transition as a result of E_two
. No valid
transition exists.
State A during
actions
(durA()
) execute and complete.
State A checks its children for valid transitions. No valid transitions exist.
State A's children are evaluated starting with state
A.A1
. State A.A1
during
actions (durA1()
)
execute and complete. State A.A1
is evaluated for
valid transitions. There are no valid transitions as a result of
E_two
within state A1
.
State A1a
's during
actions
(durA1a()
) execute.
State A.A2
is evaluated. State
A.A2
during
actions (durA2()
)
execute and complete. 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
.
State A.A2.A2a
exit
actions (exitA2a()
)
execute and complete.
State A.A2.A2a
is marked inactive.
State A.A2.A2b
is marked active.
State A.A2.A2b
entry
actions (entA2b()
)
execute and complete.
The processing of 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
. A
valid transition exists from state A.A1.A1a
to state
A.A1.A1b
.
State A.A1.A1a
executes and
completes exit
actions
(exitA1a
).
State A.A1.A1a
is marked
inactive.
State A.A1.A1b
is marked
active.
State A.A1.A1b
entry
actions (entA1b()
) execute and
complete.
Parallel state A.A2
is evaluated
next. State A.A2
during
actions (durA2()
) execute and
complete. There are no valid transitions as a result of
E_one
.
State A.A2.A2b
during
actions (durA2b()
) execute and
complete.
State A.A2.A2b
is now active as a result of the
processing of the on
event broadcast of
E_two
.
The chart goes back to sleep.
This sequence completes the execution of this Stateflow® chart associated with event E_one
and the
on
event broadcast to a parallel state of event
E_two
. The final chart activity is that parallel substates
A.A1.A1b
and A.A2.A2b
are active.
Tip
Avoid using undirected local event broadcasts. Undirected local event broadcasts can cause unwanted recursive behavior in your chart. Instead, send local events by using directed broadcasts. For more information, see Broadcast Local Events to Synchronize Parallel States.
You can set the diagnostic level for detecting undirected local event broadcasts. In the
Configuration Parameters dialog box, open the Diagnostics > Stateflow pane and set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
.
This example shows the behavior of an event broadcast transition action that includes a nested event broadcast in a parallel state. The chart uses implicit ordering of parallel states (see Implicit Ordering of Parallel States).
Initially, the chart is asleep. Parallel substates A.A1.A1a
and A.A2.A2a
are active. Event E_one
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid
transition as a result of E_one
. There is no valid
transition.
State A
during
actions (durA()
) execute
and complete.
State A's children are parallel (AND) states.
Because implicit ordering applies, the states are evaluated and executed
from left to right and top to bottom. State A.A1
is
evaluated first. State A.A1
during
actions (durA1()
) execute and complete.
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
.
State A.A1.A1a
executes and
completes exit
actions
(exitA1a
).
State A.A1.A1a
is marked
inactive.
The transition action that broadcasts event
E_two
executes and completes:
The broadcast of event E_two
now preempts
the transition from state A1a
to state
A1b
that event E_one
triggers.
The broadcast of event E_two
awakens the
chart a second time. The chart root checks to see if there is a
valid transition as a result of E_two
. No
valid transition exists.
State A during
actions
(durA()
) execute and complete.
State A's children are evaluated starting with state
A.A1
. State
A.A1
during
actions
(durA1()
) execute and complete. State
A.A1
is evaluated for valid transitions.
There are no valid transitions as a result of
E_two
within state
A1
.
State A.A2
is evaluated. State
A
.A2
during
actions (durA2()
)
execute and complete. 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
.
State A.A2.A2a
exit
actions (exitA2a()
)
execute and complete.
State A.A2.A2a
is marked inactive.
State A.A2.A2b
is marked active.
State A.A2.A2b
entry
actions (entA2b()
)
execute and complete.
State A.A1.A1b
is marked
active.
State A.A1.A1b
entry actions
(entA1b()
) execute and complete.
Parallel state A.A2
is
evaluated next. State A.A2
during actions
(durA2()
) execute and complete. There are no
valid transitions as a result of E_one
.
State A.A2.A2b
during actions
(durA2b()
) execute and complete.
State A.A2.A2b
is now active as a result of the
processing of event broadcast E_two
.
The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
and the event
broadcast on a transition action to a parallel state of event
E_two
. The final chart activity is that parallel
substates A.A1.A1b
and A.A2.A2b
are
active.
Tip
Avoid using undirected local event broadcasts. Undirected local event broadcasts can cause unwanted recursive behavior in your chart. Instead, send local events by using directed broadcasts. For more information, see Broadcast Local Events to Synchronize Parallel States.
You can set the diagnostic level for detecting undirected local event broadcasts. In the
Configuration Parameters dialog box, open the Diagnostics > Stateflow pane and set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
.
This example shows the behavior of a condition action event broadcast in a parallel (AND) state. The chart uses implicit ordering of parallel states (see Implicit Ordering of Parallel States).
Initially, the chart is asleep. Parallel substates A.A1.A1a
and
A.A2.A2a
are active. Event E_one
occurs
and awakens the chart, which processes the event from the root down through the
hierarchy:
The chart root checks to see if there is a valid
transition as a result of E_one
. No valid transition
exists.
State A
during
actions (durA()
) execute and
complete.
State A's children are parallel (AND) states. Because
implicit ordering applies, the states are evaluated and executed from top to
bottom, and from left to right. State A.A1
is evaluated
first. State A.A1
during
actions (durA1()
) execute and
complete.
State A.A1
checks for any valid
transitions as a result of event E_one
. A valid
transition from state A.A1.A1a
to state
A.A1.A1b
exists. A valid condition action also
exists. The condition action event broadcast of E_two
executes and completes. State A.A1.A1a
is still
active:
The broadcast of event E_two
awakens the
Stateflow chart a second time. The chart root checks to see if
there is a valid transition as a result of E_two
.
There is no valid transition.
State A
during
actions (durA()
)
execute and complete.
State A
's children are evaluated starting with
state A.A1
. State
A
.A1
during
actions (durA1()
)
execute and complete. State A.A1
is evaluated for
valid transitions. There are no valid transitions as a result of
E_two
within state
A1
.
State A1a
during
actions (durA1a()
)
execute.
State A.A2
is evaluated. State
A.A2
during
actions (durA2()
)
execute and complete. 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
.
State A.A2.A2a
exit
actions (exitA2a()
)
execute and complete.
State A.A2.A2a
is marked inactive.
State A.A2.A2b
is marked active.
State A.A2.A2b
entry
actions (entA2b()
)
execute and complete.
State A.A1.A1a
executes and
completes exit
actions
(exitA1a
).
State A.A1.A1a
is marked
inactive.
State A.A1.A1b
is marked
active.
State A.A1.A1b
entry
actions (entA1b()
) execute and
complete.
Parallel state A.A2
is evaluated
next. State A.A2
during
actions (durA2()
) execute and
complete. There are no valid transitions as a result of
E_one
.
State A.A2.A2b
during
actions (durA2b()
) execute and
complete.
State A.A2.A2b
is now active as a result of the
processing of the condition action event broadcast of
E_two
.
The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
and the event
broadcast on a condition action to a parallel state of event
E_two
. The final chart activity is that parallel substates
A.A1.A1b
and A.A2.A2b
are active.
Tip
Avoid using undirected local event broadcasts. Undirected local event broadcasts can cause unwanted recursive behavior in your chart. Instead, send local events by using directed broadcasts. For more information, see Broadcast Local Events to Synchronize Parallel States.
You can set the diagnostic level for detecting undirected local event broadcasts. In the
Configuration Parameters dialog box, open the Diagnostics > Stateflow pane and set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
.