This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Connect Structures in Charts to External Bus Signals

The model sfbus_demo provides examples of structures in a Stateflow® chart.

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.

Structure Definitions in sfbus_demo Stateflow Chart

Definitions of structures in the chart of the sfbus_demo model appear in the Model Explorer as follows:

Structure Definitions in sfbus_demo Stateflow Graphical Function

Definitions of structures in the graphical function get_input_signal appear in the Model Explorer as follows:

Simulink Bus Objects Define Stateflow Structures

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:

StructureFirst FieldSecond 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.

Was this topic helpful?