Documentation

简化子系统总线界面

In Bus ElementOut Bus Elementblocks provide a simplified and flexible way to use bus signals as inputs and outputs to subsystems. TheIn Bus Element块等同于Inportblock combined with aBus Selectorblock. TheOut Bus Element块等同于外港block combined with a公共汽车创建者block.

Using Bus Creator and Bus Selector Blocks

This model usesInport,Bus Selector,公共汽车创建者, and外港块。

Using Simplified Approach

Here is an equivalent model that simplifies the interface by using bus element port blocks.

To work with buses at subsystem interfaces, consider usingIn Bus ElementOut Bus Element块。This bus element port block combination:

  • 在框图中降低信号线的复杂性和混乱。

  • Makes it easy to change the interface incrementally.

  • Allows access to a bus element closer to the point of usage.

    • 对于输入,避免包含重复配置licateInportblocks and aBus Selector,Goto, and块。

    • For output, avoid a configuration that contains duplicateGoto,, and公共汽车创建者块。

Tip

To refactor a subsystem interface that usesInport,Bus Selector,公共汽车创建者, and外港blocks to useIn Bus ElementOut Bus Elementblocks, you can use Simulink®Editor action bars. For details, seeConvert Models to Use Bus Element Ports

Bus Element Ports

这simplified interface involves creating bus element ports. UseIn Bus Elementblocks to select elements from a bus signal that is fed to a subsystem. For nonbus signals (including array of buses signals) that feed a subsystem, theIn Bus Element块可以通过选择(如果没有信号)通过h the value of the input signal for use within the subsystem.

UseOut Bus Element将子系统信号组合到虚拟总线中以从子系统输出的块。

You can use bus element port blocks with virtual buses. For nonvirtual bus signals, array of buses signals, and nonbus signals, these limitations apply:

  • 对于总线信号和NONBUS信号的数组,总线元件端口块只能通过整个信号,而不是选择信号的各个元素。

  • AnOut Bus Element块从子系统输出一个虚拟总线信号。

In Bus Elementblock is of block typeInport。这Out Bus Elementblock is of block type外港。这bus element port blocks support inherited workflows. You cannot use the Block Parameters dialog box of a bus element port block to specify bus element attributes, such as data type or dimensions.

在同一子系统中,您可以将总线元件端口块的组合与Inport外港块。However, to improve the readability of the model, define a bus interface for a subsystem by using bus element port blocks throughout the subsystem.

不te

If you save a model containing bus element port blocks to a version of Simulink earlier than R2017a, Simulink converts the model to use a subsystem that containsBus Selector公共汽车创建者块,适当。

Create Bus Element Ports

For a new subsystem, creating bus element ports involves addingIn Bus Elementblocks to select subsystem input signals andOut Bus Elementblocks to create virtual bus output signals for the subsystem. For examples showing the workflow for adding bus element ports, see theIn Bus Element文档。

不te

In Bus Elementblock has two different names, depending on the Simulink library in which it appears. The functionality of both blocks is the same.

  • In the Sources library and the Ports & Subsystems library —In Bus Element

  • In the Signal Routing library —Bus Element In

Out Bus Elementblock has two different names, depending on the Simulink library in which it appears. The functionality of both blocks is the same.

  • In the Sinks library and the Ports & Subsystems library —Out Bus Element

  • In the Signal Routing library —Bus Element Out

Add In Bus Element Blocks

To add anIn Bus Elementblock, you can:

  • Drag the block from the Library Browser. This action adds a port or adds a new element if a port with the same name exists.

  • 使用快速插入。此操作增加了一个端口。

  • Copy the block from an existing block. Either use copy and paste or right-click and drag the block. If you use the right-click approach, specify whether to use the same port as the original block for new block or to add a subsystem port.

  • 在“块参数”对话框中输入信号列表中,选择一个信号,然后单击

Tip

Before selecting a signal, make sure that a bus input signal is connected to a subsystem input port.

To select a signal from the input port, use one of these approaches. To select multiple signals from an input bus signal, create multipleIn Bus Element块,每个选定信号一个。

  • Using the Block Parameters dialog box, select from the signals that are in the bus connected to this port. The signals listed in black are already selected and used in the subsystem, and signals in grey are available but are not used already. Signals in red are not available in the input bus signal. For example, signals a and b are already selected, signal c is available to select, and signal d is not available.

    After you select the signals, click

  • In the Simulink Editor, edit the element part of the block icon text. If the port is already connected outside the subsystem, you can select from a list of available signals. For example, if you did a right-click copy of an In Bus Element port block and used the existing port, you can click on text to change the selected element.

    If you delete the b (the element part of the block icon text), then you get a list of signals that you can select.

To pass through a whole signal, leave the element section of the block icon text empty.

You can specify the background color for bus element port blocks, using the Block Parameters dialog boxSet coloroption. This action sets the color of blocks associated with selected elements, or to all blocks if you do not select elements. You can change the name of the port using the Block Parameters dialog box.

Add Out Bus Element Blocks

To output multiple signals from a subsystem as a bus signal, create multipleOut Bus Elementblocks, one for each signal that you want to include in the bus. To add anOut Bus Elementblock, you can:

  • Drag the block from the Library Browser. This action adds a port or adds a new element if a port with the same name exists.

  • 使用快速插入。此操作增加了一个端口。

  • Copy the block from an existing block. Either copy and paste or right-click and drag the block. If you use the right-click approach, specify whether to use the same port as the original block for the new block or to add a subsystem port.

  • In the Block Parameters dialog box, click。To change the signal name, double-click the signal name in the tree view or in the block diagram and edit the icon text.

如果Out Bus Elementblock creates a signalA, then anotherOut Bus Elementblock for the same port cannot specify signalA(or a child of signalA) as an element.

To add a subbus, in the Block Parameters dialog box, click。To remove blocks associated with selected elements, click

You can reorder bus elements by dragging and dropping a signal in the list of signals in the Block Parameters dialog box.

You can specify the background color for bus element port blocks, using the Block Parameters dialog boxSet coloroption. This action sets the color of blocks associated with selected elements, or of all blocks if you do not select elements.

Convert Models to Use Bus Element Ports

You can refactor a subsystem interface that usesInport,Bus Selector,公共汽车创建者, and外港blocks to useIn Bus ElementOut Bus Element块。Conversion operations are supported only when the signal lines or blocks do not have any extra specification, including signal logging. You can:

  • ConvertInportBus Selectorblocks in a subsystem toIn Bus Element块。

  • Convert外港公共汽车创建者blocks in a subsystem toOut Bus Element块。

  • Transform input or output interfaces of subsystems to use bus element port blocks.

For examples that show how to convert models to use bus element ports, seeslexBusExample

Convert Subsystem Bus Selector Blocks

You can convert a subsystem that usesBus Selectorblocks to useIn Bus Elementblocks instead.

  1. Click theBus Selectorblock that is connected to theInportblock.

  2. 从the action bar, selectBus Element Ports

    这converted subsystem usesIn Bus Element块。

You can do a similar conversion for multiple layers ofBus Selector块。

  1. Perform the conversion on theBus Selectorblock that is connected to theInportblock.

  2. Convert the secondBus Selectorblock.

    不te

    This action is not available if the公共汽车创建者block output signal has a branch.

Convert Subsystem Bus Creator Blocks

You can convert a subsystem that uses公共汽车创建者blocks to useOut Bus Elementblocks instead.

  1. Click the公共汽车创建者block that is connected to the外港block.

  2. 从the action bar, selectBus Element Ports

    这converted subsystem usesOut Bus Element块。

You can do a similar conversion for multiple layers of公共汽车创建者块。

  1. Perform the conversion on the公共汽车创建者block that is connected to the外港block.

  2. Convert the second公共汽车创建者block.

Transform Subsystem Input and Output Interfaces

You can convert signals between subsystems to useIn Bus ElementOut Bus Element块。

不te

Conversion of existing subsystem inputs and outputs to use bus element ports creates virtual buses. If your model relies on the types of the original signals being nonvirtual buses, array of buses, or scalars, choose one of these options:

  • 不要执行转换。

  • 修改模型,使其与新创建的虚拟总线正常工作。

  1. Perform a marquee selection of the signals that connect two subsystems.

  2. 从the action bar, selectCreate Bus

    这conversion createsOut Bus Elementblocks in the source subsystem andIn Bus Elementblocks in the destination subsystem.

    In the converted model, there is one bus signal between the subsystems, and theBasicSrcBasicDSTsubsystems useIn Bus ElementOut Bus Elementblocks, respectively.

If the input of a subsystem is not directly connected to another subsystem, you can transform the input of the subsystem. If you transform the subsystem input, Simulink inserts a公共汽车创建者block to maintain connectivity and the subsystem usesIn Bus Element块。

  1. Perform a marquee selection of the input signals of the subsystem.

  2. 从the action bar, selectCreate Bus

这converted model uses公共汽车创建者子系统输入的块Bus Selectorblocks for subsystem outputs. The converted subsystem (Subsystem3) containsIn Bus ElementOut Bus Element块。

See Also

Blocks

相关话题

Was this topic helpful?