Contents

Bus Objects

About Bus Objects

The properties that you specify for a bus signal by using Bus Creator block parameters are inherited by all downstream blocks that use the bus. Using Bus Creator block parameters is adequate for defining virtual buses and performing limited error checking. However, to define a nonvirtual bus, or to perform complete error checking on any bus, use a bus object to specify additional information.

Creating a bus object establishes a composite data type whose name is the name of the bus object and whose properties are given by the object. A bus object specifies only the architectural properties of a bus, as distinct from the values of the signals it contains. For example, a bus object can specify the number of elements in a bus, the order of those elements, whether and how elements are nested, and the data types of constituent signals; but not the signal values.

A bus object is analogous to a structure definition in C: it defines the members of the bus but does not create a bus. A bus object is an instance of class Simulink.Bus that is defined in the base workspace. A bus object serves as the root of an ordered hierarchy of bus elements, which are instances of class Simulink.BusElement. Each element completely specifies the properties of one signal in a bus: its name, data type, dimensionality, etc. The order of the elements contained in the bus object defines the order of the signals in the bus.

Referenced models, Stateflow® charts, and MATLAB Function blocks that input and output buses require those buses to be defined with bus objects. Inport and Outport blocks can use bus objects to specify the structure of the bus passing through them. Root inport blocks use bus objects to specify the structure of the bus. Root outport blocks use bus objects to check the structure of the incoming bus and to specify the structure of the bus in the parent model, if any.

Bus Object Capabilities

You can associate a bus object with several blocks. For details, see Associating Bus Objects with Simulink Blocks.

When a bus object governs a signal output by a block, the signal is a bus that has exactly the properties specified by the object. When a bus object governs a signal input by a block, the signal must be a bus that has exactly the properties specified by the object; any variance causes an error.

A bus object can also specify properties that were not defined by constituent signals, but were left to be inherited. A property specification in a bus object can either validate or provide the corresponding property in the bus. If the bus specifies a different property, an error occurs. If the bus does not specify the property, but leaves it to be inherited, the bus inherits the property from the bus object. Note again that such inheritance never includes signal values.

You can use the Simulink® Bus Editor to create and manage bus objects, as described in Manage Bus Objects with the Bus Editor, or you can use the Simulink API, as described in Bus Object API. After you create a bus object and specify its attributes, you can associate it with any block that needs to use the bus definition that the object provides.

Associating Bus Objects with Simulink Blocks

You can associate a bus object with the following blocks:

In the Block Parameters dialog box for the block that you want to associate with a bus, set Data type to Bus: <object name> and replace <object name> with the bus object name.

    Note:   Do not set the minimum and maximum values for bus data on blocks with bus object data type. Simulink ignores these settings. Instead, set the minimum and maximum values for bus elements of the bus object specified as the data type. The values should be finite real double scalar.

    For information on the Minimum and Maximum properties of a bus element, see Simulink.BusElement.

Was this topic helpful?