Undirected Broadcast Events in Parallel States
Broadcast Events in State Actions
This example shows the behavior of event broadcast actions in 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. The states are evaluated and executed according to their labeled order. StateA.A1
is evaluated first. StateA.A1
during
actions (durA1()
) execute and complete. StateA.A1
executes and completes theon
E_one
action and broadcasts eventE_two
. Theduring
andon
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 ofE_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 evaluates its children starting with state
A.A1
. StateA.A1
during
actions (durA1()
) execute and complete. StateA.A1
is evaluated for valid transitions. There are no valid transitions as a result ofE_two
within stateA1
.The
during
actions for stateA1a
(durA1a()
) execute.State
A.A2
is evaluated. StateA.A2
during
actions (durA2()
) execute and complete. StateA.A2
checks for valid transitions. StateA.A2
has a valid transition as a result ofE_two
from stateA.A2
.A2a
to stateA.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 theon
event broadcast ofE_two
has been processed. StateA
.A1
checks for any valid transitions as a result of eventE_one
. A valid transition exists from stateA.A1.A1a
to stateA.A1.A1b
.State
A.A1.A1a
executes and completesexit
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. StateA.A2
during
actions (durA2()
) execute and complete. There are no valid transitions as a result ofE_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 theon
event broadcast ofE_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.
During simulation, Stateflow charts can detect undirected local event broadcasts. To control the level of
diagnostic action, open the Configuration Parameters dialog box and, in the Diagnostics > Stateflow pane, set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
. For more information, see Undirected event broadcasts (Simulink).
Broadcast Events in Transition Actions
This example shows the behavior of an event broadcast transition action that includes a nested event broadcast in a parallel state.
Start of Event E_one Processing
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.The children of state
A
are parallel (AND) states. The states are evaluated and executed according to their labeled order. StateA.A1
is evaluated first. StateA.A1
during
actions (durA1()
) execute and complete.State
A.A1
checks for any valid transitions as a result of eventE_one
. There is a valid transition from stateA.A1.A1a
to stateA.A1.A1b
.State
A.A1.A1a
executes and completesexit
actions (exitA1a
).State
A.A1.A1a
is marked inactive.
Event E_two Preempts E_one
The transition action that broadcasts event
E_two
executes and completes:The broadcast of event
E_two
now preempts the transition from stateA1a
to stateA1b
that eventE_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 ofE_two
. No valid transition exists.State
A
during
actions (durA()
) execute and complete.State
A
evaluates its children starting with stateA.A1
. StateA.A1
during
actions (durA1()
) execute and complete. StateA.A1
is evaluated for valid transitions. There are no valid transitions as a result ofE_two
within stateA1
.State
A.A2
is evaluated. StateA
.A2
during
actions (durA2()
) execute and complete. StateA
.A2
checks for valid transitions. StateA
.A2
has a valid transition as a result ofE_two
from stateA.A2.A2a
to stateA.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.
Event E_one Processing Resumes
State
A.A1.A1b
is marked active.State
A.A1.A1b
entry actions (entA1b()
) execute and complete.Parallel state
A.A2
is evaluated next. StateA.A2
during actions (durA2()
) execute and complete. There are no valid transitions as a result ofE_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 broadcastE_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.
During simulation, Stateflow charts can detect undirected local event broadcasts. To control the level of
diagnostic action, open the Configuration Parameters dialog box and, in the Diagnostics > Stateflow pane, set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
. For more information, see Undirected event broadcasts (Simulink).
Broadcast Events in Condition Actions
This example shows the behavior of a condition action event broadcast in a parallel (AND) state.
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.The children of state
A
are parallel (AND) states. States are evaluated and executed according to their labeled order. StateA.A1
is evaluated first. StateA.A1
during
actions (durA1()
) execute and complete.State
A.A1
checks for any valid transitions as a result of eventE_one
. A valid transition from stateA.A1.A1a
to stateA.A1.A1b
exists. A valid condition action also exists. The condition action event broadcast ofE_two
executes and completes. StateA.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 ofE_two
. There is no valid transition.State
A
during
actions (durA()
) execute and complete.State
A
evaluates its children starting with stateA.A1
. StateA
.A1
during
actions (durA1()
) execute and complete. StateA.A1
is evaluated for valid transitions. There are no valid transitions as a result ofE_two
within stateA1
.State
A1a
during
actions (durA1a()
) execute.State
A.A2
is evaluated. StateA.A2
during
actions (durA2()
) execute and complete. StateA.A2
checks for valid transitions. StateA.A2
has a valid transition as a result ofE_two
from stateA.A2.A2a
to stateA.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 completesexit
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. StateA.A2
during
actions (durA2()
) execute and complete. There are no valid transitions as a result ofE_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 ofE_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.
During simulation, Stateflow charts can detect undirected local event broadcasts. To control the level of
diagnostic action, open the Configuration Parameters dialog box and, in the Diagnostics > Stateflow pane, set the Undirected event broadcasts parameter to
none
, warning
, or
error
. The default setting is
warning
. For more information, see Undirected event broadcasts (Simulink).