主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

基于构造型层次结构改变可移植 Blender 架构中的构造型

此示例展示了如何在 System Composer™ 的可移植 Blender 架构中将构造型更改为构造型层次结构中的更高级别。处于层次结构中的构造型从基构造型继承属性。首先应用一个通用的构造型,然后更改为层次结构中更深的构造型,以进一步指定组件。

打开架构模型并将配置文件导入模型

打开 simpleBlender 模型或在命令行窗口中输入以下代码。

archModel = systemcomposer.openModel("simpleBlender");

该模型显示了一个简单的便携式搅拌机的硬件架构,其中顶层组件代表制造搅拌机的物理组件。端口代表向这些组件发送和接收电源的电源插座。

Simple blender platform architecture model.

blenderProfile 配置文件导入到模型中。在 System Composer 工具栏的建模选项卡中,选择配置文件编辑器 > 导入,或在命令行窗口中输入以下代码。

archModel.applyProfile("blenderProfile");

要查看导入的配置文件的内容,请点击配置文件编辑器以打开 配置文件编辑器,或在命令行窗口中输入以下代码。

systemcomposer.profile.editor

The blender profile is selected in the Profile Editor.

在配置文件编辑器中,您可以检查 blenderProfile 配置文件的结构。BaseStereotype 构造型是顶级构造型。再往下一个级别是 HardwareComponent 构造型,它使用 BaseStereotype 作为基构造型,从该构造型继承属性。PowerConsumerPowerGenerator 构造型从 HardwareComponent 构造型继承属性,比 BaseStereotype 构造型低两级。

将构造型应用于所有组件

要打开“应用构造型”对话框,在 System Composer 工具条的建模选项卡中,选择应用构造型。将将构造型应用于设置为 Components。将作用域设置为 Entire model。选择 blenderProfile.BaseStereotype 构造型。

Apply Stereotypes dialog box with base stereotype selected.

要将构造型 BaseStereotype(默认值为 3 kg)应用于所有组件的质量属性,请点击应用

The Housing component has the stereotype BaseStereotype applied with the value of 3 kg for the mass property.

BaseStereotype 现在应用于 Housing 组件。

更改模型中多个组件的构造型

在画布上选择 Housing 组件。在 属性检查器 中,点击 BaseStereotype 旁边的选择以找到 Housing 组件,然后选择 ↓ blenderProfile.HardwareComponentHousing 组件现在在 BaseStereotype 构造型层次结构中指定为更深一级,即 HardwareComponent 构造型。The stereotype of the Housing component is now the HardwareComponent stereotype.

Housing 组件进一步定义为硬件组件,将添加一个附加属性材料,其默认值为 "titanium"

双击 Housing 组件以查看其架构。按住 Shift 键的同时点击 BatteryOutput ShaftBlade Assembly,选择这些组件。然后,右键点击 Battery 组件,选择更改构造型,从列表中选择 ↓ blenderProfile.HardwareComponent 构造型。现在,HardwareComponent 构造型已应用于这三个组件。

The battery, output shaft, and blade assembly components are now hardware components.

在模型画布中点击一次,取消选择所有组件。右键点击 Battery 组件,选择更改构造型,然后选择 ↓ blenderProfile.PowerGenerator 构造型。对 Output ShaftBlade Assembly 组件重复上述操作,但选择 ↓ blenderProfile.PowerConsumer 构造型。

The Battery component with the PowerGenerator stereotype applied and the PowerOut property value ready to be set.

在属性检查器中,您现在可以根据需要为 BatteryOutput ShaftBlade Assembly 组件指定 powerInpowerOut 属性。

另请参阅

工具

模块

对象

函数

主题