The chart contains a graphical function.
In this model, the Stateflow chart receives a bus input signal using the structure inbus at input port 1 and outputs a bus signal from the structure outbus at output port 1. The input signal comes from the Simulink® Bus Creator block COUNTERBUSCreator, which bundles signals from two other Bus Creator blocks: SIGNALBUSCreator and LIMITBUSCreator. The structure outbus connects to a Simulink Bus Selector block BUSSelector. The Stateflow chart also contains a local structure counterbus_struct and a graphical function get_input_signal that contains an input structure u and output structure y.
Definitions of structures in the chart of the sfbus_demo model appear in the Model Explorer as follows:
Note: The local structure counterbus_struct is defined using the type operator in an expression, as described in Define Structure Types with Expressions.
Definitions of structures in the graphical function get_input_signal appear in the Model Explorer as follows:
Each Stateflow structure must be defined by a Simulink.Bus object in the base workspace. The structure shares the same properties as the bus object, including number, name, and type of fields. For example, the sfbus_demo model defines the following bus objects in the base workspace:
You can find the bus object that defines a Stateflow structure by looking in the Data Type and Compiled Type columns in the Contents pane of the Model Explorer. For example, the structures inbus, outbus, and counterbus_struct are all defined in sfbus_demo by the same Simulink bus object, COUNTERBUS.
Based on these definitions, inbus, outbus, and counterbus_struct have the same properties as COUNTERBUS. For example, these Stateflow structures in sfbus_demo reference their fields by the same names as the elements in COUNTERBUS, as follows:
|Structure||First Field||Second Field|
To learn how to define structures in Stateflow charts using Simulink.Bus objects, see Define Stateflow Structures.
If you define a custom structure in C for your Stateflow chart, you must make sure that the structure's typedef declaration in your header file matches the properties of the Simulink.Bus object that defines the structure, as described in Integrate Custom Structures in Stateflow Charts.