| Stateflow User's Guide | ![]() |
Importing Events from Stateflow External Code
A Stateflow machine serves as a surrogate parent for imported events defined by external code. Importing an event allows Stateflow to build a custom or Real-Time Workshop (RTW) target, that triggers the imported event in external code.
To import an event, add an event to the Stateflow machine that needs to trigger the event and set its Scope property to Imported.
| Note You must use the Model Explorer to add imported events to the Stateflow machine. For information on adding events in the Model Explorer, see Adding Events in the Model Explorer. |
Stateflow assumes that external code defines each imported event as a function whose prototype is of the form
where EVENT is the Stateflow name of the imported event. For example, suppose that the Stateflow machine imports an external event named switch_on. In this case, Stateflow assumes that external code defines a function named external_broadcast_switch_on that broadcasts the event to external code. Later, when you build a target for the Stateflow 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.
See Imported Events for an example of a Stateflow external code event imported into Stateflow.
| Exporting Events to Stateflow External Code | Defining Implicit Events | ![]() |
© 1994-2005 The MathWorks, Inc.