Main Content

简化与总线的子系统和模型接口

Buses allow you to simplify subsystem and model interfaces with在公交元素中and出去公交元素块。这些块:

  • Reduce signal line complexity and clutter in a block diagram.

  • 使更容易逐步更改接口。

  • 允许访问更接近其使用点的元素。

You can use these blocks instead ofInportand总线选择器输入的块OutportandBus Creator块outputs. For example, this model usesInport,,,,总线选择器,,,,Bus Creator,,,,andOutport块。

总线选择器and Bus Creator blocks modify the input bus.

这种等效模型使用在公交元素中and出去公交元素块。

在总线元素和外出总线元件中,使框图更容易解析。

小费

For virtual buses at interfaces, use在公交元素中and出去公交元素块。这些块支持多段虚拟巴士,不金宝app需要金宝appsimulink.bus对象,不同InportandOutport块。

Use Buses at Subsystem Interfaces

金宝app®可以帮助您更新以要使用的子系统界面在公交元素中and出去公交元素块。从动作栏中,您可以:

这些动作在模型接口上不可用。有关模型接口处的公交车的更多信息,请参见在型号接口处使用巴士

这些操作也无法用于具有额外规格的信号线和块,包括信号名称和记录。额外的规格会造成潜在的冲突。

以下示例说明了如何使用动作栏更新子系统接口。示例模型很简单,但是,当您有许多信号可以组合时,总线最有用。

简化子系统中的总线接口

此示例显示了如何转换使用INPORT,BUS选择器,总线创建器和外口块以在总线元素和OUT BUS元素块中使用的接口。

Open and simulate the example model, which contains a subsystem that modifies an input bus hierarchy using Bus Selector and Bus Creator blocks. The subsystem uses Inport and Outport blocks for input and output.

Open the subsystem.

要在总线元素块中转换内部和总线选择器块:

  1. 单击直接连接到Inport块的总线选择器块。

  2. 在您暂停省略号时出现的动作栏中,单击公交端口

您可以类似地转换总线元素和总线选择器块。

To convert Outport and Bus Creator blocks to Out Bus Element blocks:

  1. 单击直接连接到不分支的出口块的总线创建器块。

  2. 在您暂停省略号时出现的动作栏中,单击公交端口

You can similarly convert Out Bus Element and Bus Creator blocks.

The resulting model simplifies line routing, makes it easier to incrementally change the interface, and lets you access elements closer to their point of usage.

You can change the name of a bus and its elements by double-clicking the block labels and editing them.

要轻松识别同一嵌套总线或总线端口的元素,请指定块颜色。

  1. Double-click an In Bus Element or Out Bus Element block to open the dialog box for the related port.

  2. 选择一个元素或顶级总线。

  3. 设置颜色下拉式菜单。

将多个子系统端口组合到一个端口

该示例通过将多个端口及其连接的信号转换为一个端口和总线来简化子系统接口的三种方法。

Open the example model, which contains two subsystems with multiple input and output ports.

Drag a selection box around the signal lines between the two subsystems. From the action bar that appears, click创建巴士

金宝appSimulink用总线元素和OUT BUS元素块替换了源和目标子系统中的内部和出口块。

在源块和第一个子系统之间的信号线周围拖动一个选择框。从出现的动作栏中,单击创建巴士

金宝appSimulink在第一个子系统之前添加了一个总线创建器块,并用总线元素块中的第一个子系统替换了第一个子系统中的Inport块。

在第二子系统和范围块之间的信号线周围拖动一个选择框。从出现的动作栏中,单击创建巴士

Simulink replaces the Outport blocks in the second subsystem with Out Bus Element blocks and adds a Bus Selector block after the second subsystem.

The resulting model uses virtual buses at the subsystem interfaces.

在型号接口处使用巴士

公交输入Model块必须与参考模型预期的总线一致。

If you use a bus as an input to or an output from a referenced model:

  • 只有非虚拟总线可以包含可变大小的信号元素。

  • 对于代码生成,您只能配置i/o参数步骤方法style of C++ class interface for the referenced model when using a nonvirtual bus or when using theDefaultC ++类接口的样式。

  • 对于代码生成,您只能在使用非虚拟总线时为引用模型配置函数原型控件。

也可以看看

|

Related Topics