| Contents | Index |
| On this page… |
|---|
Example of Directed Event Broadcasting Using send Example of Directed Event Broadcasting Using Qualified Event Names |
In the action language, you can broadcast events directly from one state to another to synchronize parallel (AND) states in the same chart. 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 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 Guidelines for Avoiding Unwanted Recursion in a Chart.
The format of the directed 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)
Tip Do not use the chart name in the full hierarchy path to a state. Formal chart names include the subsystem in which a chart resides. For example, in the model sldemo_fuelsys, the chart control_logic is in the subsystem fuel_rate_control. The formal name for the chart is fuel_rate_control/control_logic. This name includes the forward slash character ('/'), which is not a valid character in Stateflow identifiers. |
This example of a directed event broadcast uses the send(event_name,state_name) syntax.

In this example, event E_one belongs to the chart and is visible to both A and B. See Directed Event Broadcast Using Send Example for information on the semantics of this notation.
The format of the direct event broadcast using qualified event names is:
state_name.event_name
where event_name is broadcast to its owning state (state_name) and any offspring of that state in the hierarchy. The event you send is visible only to the receiving state (state_name).
The state_name 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.
The following example illustrates the use of a qualified event name in a directed 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 Example for information on the semantics of this notation.
![]() | Using Arrays in Actions | Using Temporal Logic in State Actions and Transitions | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |