Stateflow | ![]() ![]() |
Defining Local Events
A local event is an event that can occur anywhere in a Stateflow machine but is visible only in its parent (and its parent's descendants). To define an event as local, set its Scope
property to Local
.
Defining Input Events
An input event occurs outside a chart and is visible only in that chart. This type of event allows other Simulink blocks, including other Stateflow blocks, to notify a particular chart of events that occur outside it. To define an event as an input event, set its Scope
property to Input from Simulink
.
You can define multiple input events for a chart. The first time you define an input event for a chart, Stateflow adds a trigger port to the chart's block. External blocks can trigger the chart's input events via a signal or vector of signals connected to the chart's trigger port by associating input events with control signals. When defining input events for a chart, you must specify how control signals connected to the chart trigger the input events (see Specifying Trigger Types).
You can also add input events to a chart from Simulink in the Stateflow Explorer. See Adding Input Events from Simulink.
Associating Input Events with Control Signals
An input event's Index
property associates the event with a specific element of a control signal vector connected to the trigger port of the chart that parents the event. The first element of the signal vector triggers the input event whose index is 1; the second, the event whose index is 2; and so on. Stateflow assigns 1 as the index of the first input event that you define for a chart, 2 as the index of the second event, and so on. You can change the default association for an event by setting the event's Index
property to the index of the signal that you want to trigger the event.
Input events occur in ascending order of their indexes when more than one such event occurs during update of a chart (see Setting the Stateflow Block Update Method). For example, suppose that when defining input events for a chart, you assign the indexes 3, 2, and 1 to events named A, B, and C, respectively. Now, suppose that, during simulation of the model containing the chart, that events A and C occur in a particular update. Then, in this case, the order of occurrence of the events is C first followed by A.
Defining Output Events
An output event is an event that occurs in a specific chart and is visible in specific blocks outside the chart. This type of event allows a chart to notify other blocks in a model of events that occur in the chart. To define an event as an output event, set its Scope
property to Output to Simulink
. You can define multiple output events for a given chart. Stateflow creates a chart output port for each output event that you define (see Port). Your model can use the output ports to trigger the output events in other Simulink blocks in the same model.
You can also add output events to a chart from Simulink in the Stateflow Explorer. See Adding Output Events to Simulink.
Associating an Output Event with an Output Port
An output event's Port
property associates the event with an output port on the chart block that parents the event. The property specifies the position of the port relative to other event ports on the Chart block. Event ports appear below data ports on the right side of a chart block. Stateflow numbers ports sequentially from top to bottom, starting with port 1. Stateflow assigns port 1 to the first output event that you define for a chart, port 2 to the second output event, and so on. You can change the default port assignment of an event by resetting its Port
property or by selecting the output event in the Explorer and dragging and dropping it to the desired position in the list of output events.
![]() | Setting Event Properties | Exporting Events | ![]() |