Stateflow    

Importing Data

A state machine can import definitions of data defined by external code that embeds the state machine. Importing externally defined data enables a state machine to access data defined by the system in which it is embedded. To import an externally defined data item into a state machine, add a default item to the data dictionary as a child of the state machine. Then set the new item's Scope property to Imported, its Name property to the name used by the machine's actions to reference the item, and its other properties (i.e., Type, Initial Value, etc.) to appropriate values.

The Stateflow code generator assumes that external code provides a prototype for each imported item of the form

where type is the C data type corresponding to the Stateflow data type of the imported item (e.g., int for Integer, double for Double, etc.) and data is the item's Stateflow name. For example, suppose that your state machine defines an imported integer item named counter. The Stateflow code generator expects the item to be define in the external C code as


 Exporting Data Documenting Data