Stateflow | ![]() ![]() |
Importing Events
A state machine can import events defined by external code. Importing an event allows a state machine built into a stand-alone or Real-Time Workshop target to trigger the event in external code. To import an event, first add the event to the data dictionary as a child of the state machine that needs to trigger the event (see Adding Events to the Data Dictionary). Then set the new event's Scope
property to Imported
.
Note The state machine serves as a surrogate parent for imported events. This means that you must use the Explorer to add imported events to the data dictionary. |
Stateflow assumes that external code defines each imported event as a function whose prototype is of the form
void external_broadcast_EVENT
where EVENT
is the Stateflow name of the imported event. For example, suppose that a state machine imports an external event named switch_on
. Then Stateflow assumes that external code defines a function named external_broadcast_switch_on
that broadcasts the event to external code. When encoding the state machine, the Stateflow code generator encodes actions that signal imported events as calls to the corresponding external broadcast event functions defined by the external code.
![]() | Exporting Events | Specifying Trigger Types | ![]() |