Stateflow | ![]() ![]() |
Exporting Data
Stateflow can export definitions of state machine data to external code that embeds the state machine. Exporting data enables external code, as well as the state machine, to access the data. To export a data item, first add it to the data dictionary as the child of the state machine in which it is defined. Then set its Scope
property to Exported
and its other properties (e.g., Name
and Type
) to appropriate values.
The Stateflow code generator generates a C declaration for each exported data item of the form
type ext_data;
where type
is the C type of the exported item (e.g., int
, double
) and data
is the item's Stateflow name. For example, suppose that your state machine defines an exported integer
item named counter
. The Stateflow code generator exports the item as the C declaration
int ext_counter;
The code generator includes declarations for exported data in the generated target's global header file, thereby making the declarations visible to external code compiled into or linked to the target.
![]() | Defining Temporary Data | Importing Data | ![]() |