Documentation

Simulink.Bus

Specify properties of signal bus

Description

Objects of this class (in conjunction with objects of the Simulink.BusElement class) specify the properties of a bus signal. Use bus objects to have Simulink® validate the properties of buses connected to the inputs of blocks in your model. In the Data type parameter of a Block Parameters dialog box, enter the name of a bus object that defines a bus. When you update the model diagram or start a simulation of the model, Simulink checks whether the buses connected to the blocks have the properties specified by the bus objects. If not, Simulink halts and displays an error message.

Some of the blocks that support using a bus object as a data type include:

For a complete list of blocks that support using a bus object as a data type, see When to Use Bus Objects.

You can use the Simulink Bus editor (see Create Bus Objects with the Bus Editor), or MATLAB® commands (see Create Bus Objects Programmatically) to create and modify bus objects in the base MATLAB workspace.

When you use the Bus Editor, you create Simulink.Bus and Simulink.BusElement objects in the base workspace. To open the Bus Editor, you can use the buseditor command.

Property Dialog Box

Bus elements

Table that displays the properties of the bus elements. You cannot edit this table. You must use either the Simulink Bus editor (see Modify Bus Objects) or MATLAB commands to add or delete bus elements or change the properties of existing bus elements. To launch the bus editor, click the Launch Bus editor button at the bottom of this dialog box or in the Simulink Editor, select Edit > Bus EditorBus editor.

Data scope

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation. The possible values are:

ValueAction
Auto (default)If no value is specified for Header file, export the data type definition to model_types.h, where model is the model name.

If a value is specified for Header file, import the data type definition from the specified header file.
ExportedExport the data type definition to a header file, which can be specified in the Header file field. If no value is specified for Header file, the header file name defaults to type.h, wheretype is the data type name.
ImportedImport the data type definition from a header file, which can be specified in the Header file field. If no value is specified for Header file, the header file name defaults to type.h, wheretype is the data type name.

For additional information, see Group Signals into Structures in the Generated Code Using Buses.

Header file

Name of a C header file from which a data type definition is imported, or to which a data type definition is exported, based on the value of Data scope. This field is intended for use by Simulink Coder™ software. Simulink software ignores this field.

By default, the generated #include directive uses the preprocessor delimiter " instead of < and >. To generate the directive #include <myTypes.h>, specify Header file as <myTypes.h>.

For additional information, see Group Signals into Structures in the Generated Code Using Buses.

Alignment

Data alignment boundary, specified in number of bytes. The starting memory address for the data allocated for the bus will be a multiple of the Alignment setting. The default value is -1, which specifies that the code generator should determine an optimal alignment based on usage. Otherwise, specify a positive integer that is a power of 2, not exceeding 128. This field is intended for use by Simulink Coder software. See Data Alignment for Code Replacement. Simulink software ignores this field.

Description

Description of this structure. This field is intended for you to use to document this bus. Simulink software does not use this field.

Properties

Name

Access

Description

Alignment

RW

Integer value specifying a data alignment boundary, in number of bytes. This property is intended for use by Simulink Coder software. Simulink software does not use it. (Alignment)

DataScope

RW

A character vector specifying whether the data type definition should be imported from, or exported to, a header file during code generation. (Data scope)

Description

RW

A character vector that describes this bus. This property is intended for user use. Simulink software does not use it. (Description)

Elements

RW

An array of Simulink.BusElement objects that define the names, data types, dimensions, and other properties of the bus's elements. The elements must have unique names. (Bus elements)

HeaderFile

RW

A character vector that specifies the name of a C header file from which a data type definition is imported, or to which a data type definition is exported, during code generation. (Header file)

Introduced before R2006a

Was this topic helpful?