Download Stateflow User's Guide

Transcript
Defining Events
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” on page 6-7). 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” on page 8-7.
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.
Exporting Events
Stateflow allows a Stateflow machine to export events. Exporting events
enables external code to trigger events in the Stateflow machine. To export an
event, first add the event to the data dictionary as a child of the Stateflow
machine (see “Adding Events to the Data Dictionary” on page 6-2). Then set the
new event’s Scope property to Exported.
6-9