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
Aduringactions (durA()) execute and complete.The children of state
Aare parallel (AND) states. The states are evaluated and executed according to their labeled order. StateA.A1is evaluated first. StateA.A1duringactions (durA1()) execute and complete. StateA.A1executes and completes theonE_oneaction and broadcasts eventE_two. Theduringandonevent_nameactions are processed based on their order of appearance in the state label:The broadcast of event
E_twoawakens 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
duringactions (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.A1duringactions (durA1()) execute and complete. StateA.A1is evaluated for valid transitions. There are no valid transitions as a result ofE_twowithin stateA1.The
duringactions for stateA1a(durA1a()) execute.State
A.A2is evaluated. StateA.A2duringactions (durA2()) execute and complete. StateA.A2checks for valid transitions. StateA.A2has a valid transition as a result ofE_twofrom stateA.A2.A2ato stateA.A2.A2b.State
A.A2.A2aexitactions (exitA2a()) execute and complete.State
A.A2.A2ais marked inactive.State
A.A2.A2bis marked active.State
A.A2.A2bentryactions (entA2b()) execute and complete.
The processing of
E_onecontinues once theonevent broadcast ofE_twohas been processed. StateA.A1checks for any valid transitions as a result of eventE_one. A valid transition exists from stateA.A1.A1ato stateA.A1.A1b.State
A.A1.A1aexecutes and completesexitactions (exitA1a).State
A.A1.A1ais marked inactive.State
A.A1.A1bis marked active.State
A.A1.A1bentryactions (entA1b()) execute and complete.Parallel state
A.A2is evaluated next. StateA.A2duringactions (durA2()) execute and complete. There are no valid transitions as a result ofE_one.State
A.A2.A2bduringactions (durA2b()) execute and complete.State
A.A2.A2bis now active as a result of the processing of theonevent 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
Aduringactions (durA()) execute and complete.The children of state
Aare parallel (AND) states. The states are evaluated and executed according to their labeled order. StateA.A1is evaluated first. StateA.A1duringactions (durA1()) execute and complete.State
A.A1checks for any valid transitions as a result of eventE_one. There is a valid transition from stateA.A1.A1ato stateA.A1.A1b.State
A.A1.A1aexecutes and completesexitactions (exitA1a).State
A.A1.A1ais marked inactive.
Event E_two Preempts E_one
The transition action that broadcasts event
E_twoexecutes and completes:The broadcast of event
E_twonow preempts the transition from stateA1ato stateA1bthat eventE_onetriggers.The broadcast of event
E_twoawakens 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
Aduringactions (durA()) execute and complete.State
Aevaluates its children starting with stateA.A1. StateA.A1duringactions (durA1()) execute and complete. StateA.A1is evaluated for valid transitions. There are no valid transitions as a result ofE_twowithin stateA1.State
A.A2is evaluated. StateA.A2duringactions (durA2()) execute and complete. StateA.A2checks for valid transitions. StateA.A2has a valid transition as a result ofE_twofrom stateA.A2.A2ato stateA.A2.A2b.State
A.A2.A2aexitactions (exitA2a()) execute and complete.State
A.A2.A2ais marked inactive.State
A.A2.A2bis marked active.State
A.A2.A2bentryactions (entA2b()) execute and complete.
Event E_one Processing Resumes
State
A.A1.A1bis marked active.State
A.A1.A1bentry actions (entA1b()) execute and complete.Parallel state
A.A2is evaluated next. StateA.A2during actions (durA2()) execute and complete. There are no valid transitions as a result ofE_one.State
A.A2.A2bduring actions (durA2b()) execute and complete.State
A.A2.A2bis 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
Aduringactions (durA()) execute and complete.The children of state
Aare parallel (AND) states. States are evaluated and executed according to their labeled order. StateA.A1is evaluated first. StateA.A1duringactions (durA1()) execute and complete.State
A.A1checks for any valid transitions as a result of eventE_one. A valid transition from stateA.A1.A1ato stateA.A1.A1bexists. A valid condition action also exists. The condition action event broadcast ofE_twoexecutes and completes. StateA.A1.A1ais still active:The broadcast of event
E_twoawakens 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
Aduringactions (durA()) execute and complete.State
Aevaluates its children starting with stateA.A1. StateA.A1duringactions (durA1()) execute and complete. StateA.A1is evaluated for valid transitions. There are no valid transitions as a result ofE_twowithin stateA1.State
A1aduringactions (durA1a()) execute.State
A.A2is evaluated. StateA.A2duringactions (durA2()) execute and complete. StateA.A2checks for valid transitions. StateA.A2has a valid transition as a result ofE_twofrom stateA.A2.A2ato stateA.A2.A2b.State
A.A2.A2aexitactions (exitA2a()) execute and complete.State
A.A2.A2ais marked inactive.State
A.A2.A2bis marked active.State
A.A2.A2bentryactions (entA2b()) execute and complete.
State
A.A1.A1aexecutes and completesexitactions (exitA1a).State
A.A1.A1ais marked inactive.State
A.A1.A1bis marked active.State
A.A1.A1bentryactions (entA1b()) execute and complete.Parallel state
A.A2is evaluated next. StateA.A2duringactions (durA2()) execute and complete. There are no valid transitions as a result ofE_one.State
A.A2.A2bduringactions (durA2b()) execute and complete.State
A.A2.A2bis 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).