Main Content

将接口分配给端口

端口接口描述了可以在系统Composer™体系结构模型中端口之间传递的数据。界面中的数据元素描述了界面上传输的数据的特征。数据元素可以描述数据接口,传输消息或组件之间共享的数据结构的组成。

对于接口术语,请参阅Define Port Interfaces Between Components

此主题将向您展示如何:

  • Use the Property Inspector to assign data interfaces to one port at a time or the Interface Editor to assign data interfaces to multiple ports.

  • 管理端口本地的自有接口,而不是在数据词典中共享的。

  • 将接口分配给多个端口。

  • 通过端口连接组件,并指定连接的源元素或目标元素。

连接两端的不兼容的数据接口可以与Adapter块使用接口适配器

To manage interfaces shared between models in data dictionaries, seeManage Interfaces with Data Dictionaries

带有接口的移动机器人体系结构模型

此示例显示了带有接口的移动机器人平台体系结构。

将端口与属性检查器中的接口相关联

To assign data interfaces or value types to one port at a time, use the Property Inspector. To open the Property Inspector, navigate to造型>设计>物业检查员。To show theSensordataport properties, select the port in the model. Expand界面,从姓名列表,选择Sensordata关联SensordataSensordataport.

The Property Inspector is open. The sensor data interface is selected in the Interface list.

定义端口本地自有的接口

您可以从属性Inspector中的模型数据字典中选择一个值类型或数据接口,也可以创建一个自有的接口。一个owned interface是一个本地定义的接口,是特定端口本地的,而在数据字典或模型词典中未共享的接口。创建一个自有的接口来表示端口本地的值类型或数据接口。

笔记

自有的接口和值类型没有自己的名称,因为它们是端口本地的,而没有共享的。自有接口的名称是从端口名称派生的。

使用属性Inspector管理拥有的接口

您可以编辑属性检查器中自有界面的数据。选择停靠建筑端口。在财产检查员中,界面, 来自姓名列表,选择

一个owned interface in the Property Inspector.

默认情况下,自有界面停靠成为自有的价值类型。直接在属性检查器中编辑接口属性,或选择在接口编辑器中打开至edit the owned value type interface.

对接端口的接口编辑器中拥有的值类型。

要将拥有的值类型转换为拥有的数据接口,请单击添加数据元素至add a data element.

使用接口编辑器管理拥有的接口

您也可以专门从接口编辑器工作。选择名称的组件端口Feedback。在接口编辑器中,从字典视图端口接口视图

选择端口接口视图ion in the Interface Editor.

点击添加数据元素至添加数据元素s to the owned data interface.

接口编辑器中的端口接口视图中拥有的数据元素。

To convert the owned data interface to an owned value type, change theType为了Feedback至a valid MATLAB®data type, such as

选择多个端口并分配数据接口

多个端口,无论是否连接,都可以使用相同的数据接口定义。当您将数据接口分配到端口时,只要它们尚未具有分配,将自动将接口传播到连接的端口。要简化批处理分配,请选择多个端口,右键单击数据接口,然后选择分配选定的端口

Highlight the ports that use a data interface definition by clicking the interface name in the Interface Editor.

The interface named 'sensor data' is selected in the Interface Editor. The ports that are associated with it are highlighted in purple in the model.

Specify a Source Element or Destination Element for Ports on a Connection

For connections between the root architecture and a component within the architecture model, you can add a source element or destination element to the ports.

  1. 创建一个称为的组件马达and connect it to the root architecture with ports namedMotionDataandSpeedData

  2. Define the data interfaceWheel使用数据元素RotationSpeedand最大速度

  3. 分配Wheel数据接口到连接上的端口。

  4. 选择MotionData组件上的端口名称。出现一个点和数据元素列表。从列表中选择源元素RotationSpeed

  5. 分配最大速度目标元素SpeedDataport.

The interface element rotation speed is the source element for the motion data port on the motor component.

也可以看看

功能

Blocks

Related Topics