You can broadcast events directly from one state to another to synchronize parallel (AND) states in the same chart. Local events are supported only in Stateflow® charts in Simulink® models. The following rules apply:
The receiving state must be active during the event broadcast.
An action in one chart cannot broadcast events to states in another chart.
Using a directed local event broadcast provides the following benefits over an undirected broadcast:
Prevents unwanted recursion during simulation.
Improves the efficiency of generated code.
For information about avoiding unwanted recursion, see Avoid Unwanted Recursion in a Chart.
send
The format of a directed local event broadcast with send
is:
send(event_name,state_name)
where event_name
is broadcast to
state_name
and any offspring of that state in the hierarchy.
The event you send must be visible to both the sending state and the receiving state
(state_name
).
The state_name
argument can include a full hierarchy path to
the state. For example, if the state A
contains the state
A1
, send an event E
to state A1
with the following broadcast:
send(E,A.A1)
Do not include the chart name in the full hierarchy path to a state.
The following example of a directed local event broadcast uses the
send(
syntax.event_name
,state_name
)
In this example, event E_one
belongs to the chart and is visible to
both A
and B
. See Directed Event Broadcast Using Send for more
information on the semantics of this notation.
The format of a directed local event broadcast using qualified event names is:
send(state_name.event_name)
where
is broadcast to its
owning state (event_name
) and any offspring of
that state in the hierarchy. The event you send is visible only to the receiving state
(state_name
). state_name
The
argument can also include a
full hierarchy path to the receiving state. Do not use the chart name in the full path name
of the state.state_name
The following example shows the use of a qualified event name in a directed local event broadcast.
In this example, event E_one
belongs to state B
and is visible only to that state. See Directed Event Broadcast Using Qualified Event Name for more
information on the semantics of this notation.
If you have undirected local event broadcasts in state actions or condition actions in your chart, a warning appears by default during simulation. Examples of state actions with undirected local event broadcasts include:
entry: send(E1)
, where E1
is a local event in
the chart
exit: E2
, where E2
is a local event in the
chart
You can control the level of diagnostic action for undirected local event broadcasts in
the Diagnostics > Stateflow pane of the Model Configuration Parameters dialog box. Set the
Undirected event broadcasts diagnostic to
none
, warning
, or
error
. For more information, see the documentation for the
Undirected event broadcasts (Simulink) diagnostic.