主要内容

systemcomposer.interface.PhysicalElement

物理元素物理接口

描述

一个PhysicalElement对象代表一个物理元素在一个物理接口。

创建

创建一个使用物理元素addElement函数。

元素= addElement(接口,“newPhysicalElement”)

属性

全部展开

父母物理接口的物理元素,指定为一个systemcomposer.interface.PhysicalInterface对象。

物理元素名称,指定为一个字符或字符串向量。

例子:“newPhysicalElement”

数据类型:字符|字符串

类型的物理元素,指定为一个systemcomposer.interface.PhysicalInterfacesystemcomposer.interface.PhysicalDomain矢量对象或一个字符或字符串的部分物理域名。有效的物理域名的列表,请参阅特定领域的线条样式(Simscape)

通用唯一标识符的物理元素,指定为一个特征向量。

例子:91 d5de2c-b14c-4c76-a5d6-5dd0037c52df

数据类型:字符

独特的外部标识符指定为一个特征向量。外部ID是保存在物理元素的寿命和保存的所有操作UUID

数据类型:字符

对象的功能

setName 设置名称值类型、函数参数界面,或元素
摧毁 删除模型元素

例子

全部折叠

构建一个架构模型以编程方式使用系统作曲家™。

构建模型

建立一个模型,添加一个数据字典,数据接口,数据元素,一个值类型,和一个物理接口,然后添加组件,港口,和连接。创建一个配置文件和原型和属性,然后应用这些模型元素的刻板印象。分配一个拥有接口端口。模型建立后,您可以创建自定义视图关注具体的注意事项。你也可以查询模型收集不同的模型元素根据您指定的标准。

添加组件、港口、连接和接口

创建一个模型,提取其体系结构。

模型= systemcomposer.createModel (“mobileRobotAPI”);拱= model.Architecture;

创建一个接口数据字典,并添加一个数据接口。添加一个数据元素的数据接口。值类型添加到接口数据字典。赋值类型的数据元素的类型。添加一个物理接口和物理元素与一个物理域类型。链接模型的数据字典。

字典= systemcomposer.createDictionary (“SensorInterfaces.sldd”);界面= dictionary.addInterface (“GPSInterface”);元素= interface.addElement (“SignalStrength”);valueType = dictionary.addValueType (“SignalStrengthType”单位=“数据库”、描述=“GPS信号强度”);element.setType (valueType);physicalInterface = dictionary.addPhysicalInterface (“PhysicalInterface”);physicalElement = addElement (physicalInterface,“ElectricalElement”类型=“electrical.electrical”);linkDictionary(模型,“SensorInterfaces.sldd”);

将更改保存到数据字典的接口。

dictionary.save

保存模型。

model.save

打开模型。

systemcomposer.openModel (“mobileRobotAPI”);

在接口编辑器中查看接口。

添加组件、端口和连接。设置物理接口的物理端口,稍后您将连接。

componentSensor = addComponent(拱门,“传感器”);sensorPorts = addPort (componentSensor.Architecture, {“MotionData”,“SensorPower”},{“在”,“物理”});sensorPorts (2) .setInterface (physicalInterface) componentPlanning = addComponent(拱门,“计划”);planningPorts = addPort (componentPlanning.Architecture, {“命令”,“SensorPower1”,“MotionCommand”},{“在”,“物理”,“出”});planningPorts (2) .setInterface (physicalInterface) componentMotion = addComponent(拱门,“运动”);motionPorts = addPort (componentMotion.Architecture, {“MotionCommand”,“MotionData”},{“在”,“出”});

创建一个接口上的所有“MotionData”端口。添加一个拥有数据元素下的所有数据接口。分配数据元素”旋转”与单位设置为值类型

ownedInterface = motionPorts (2) .createInterface (“DataInterface”);ownedElement = ownedInterface.addElement (“旋转”);子接口= ownedElement.createOwnedType(单位=“度”);

在接口编辑器中查看接口。选择“MotionData”港口运动组件。在接口编辑器中,切换字典视图港口界面视图

连接组件接口规则和规则默认名称。接口规则连接端口组件共享相同的接口。默认情况下,这个名字规则连接端口组件共享相同的名称。

c_sensorData =连接(拱门,componentSensor componentPlanning,规则=“界面”);c_motionData =连接(拱门,componentMotion componentSensor);c_motionCommand =连接(拱门,componentPlanning componentMotion);

添加和连接架构端口

添加一个架构港口体系结构。

archPort = addPort(拱门,“命令”,“在”);

连接命令需要一个组件端口作为参数。获取组件的端口,然后连接。

compPort = getPort (componentPlanning,“命令”);c_Command =连接(archPort compPort);

保存模型。

model.save

由pressıng安排布局Ctrl + Shift +一个或者使用这个命令。

金宝appSimulink.BlockDiagram.arrangeSystem (“mobileRobotAPI”);

创建和应用概要文件与刻板印象

概要文件是XML文件,可以应用于任何模型。你可以添加构造型属性配置文件,然后填充属性与特定的值。随着系统作曲家的内置分析功能,刻板印象帮助您优化系统性能,成本和可靠性。

创建概要文件和添加构造型

创建一个概要文件。

形象= systemcomposer.createProfile (“GeneralProfile”);

创建一个原型,它适用于所有的元素类型。

elemSType = addStereotype(概要文件,“projectElement”);

为不同类型的组件创建原型。你可以选择这些类型是基于你的设计需求。

pCompSType = addStereotype(概要文件,“physicalComponent”AppliesTo =“组件”);sCompSType = addStereotype(概要文件,“softwareComponent”AppliesTo =“组件”);

为连接创建一个原型。

sConnSType = addStereotype(概要文件,“standardConn”AppliesTo =“连接器”);

添加属性

将属性添加到刻板印象。您可以使用属性来获取元数据模型元素和分析非功能性需求。这些属性被添加到所有的原型所应用的元素,在任何进口这个概要文件的模型。

addProperty (elemSType“ID”类型=“uint8”);addProperty (elemSType“描述”类型=“字符串”);addProperty (pCompSType“成本”类型=“替身”单位=“美元”);addProperty (pCompSType“重量”类型=“替身”单位=“g”);addProperty (sCompSType“develCost”类型=“替身”单位=“美元”);addProperty (sCompSType“develTime”类型=“替身”单位=“小时”);addProperty (sConnSType“unitCost”类型=“替身””,单位=“美元”);addProperty (sConnSType“unitWeight”类型=“替身”单位=“g”);addProperty (sConnSType“长度”类型=“替身”单位=“m”);

保存配置文件

profile.save;

概要文件应用到模型

这个概要文件应用到模型。

applyProfile(模型,“GeneralProfile”);

对组件应用的刻板印象。一些组件是物理组件,而另一些则软件组件。

applyStereotype (componentPlanning“GeneralProfile.softwareComponent”)applyStereotype (componentSensor“GeneralProfile.physicalComponent”)applyStereotype (componentMotion“GeneralProfile.physicalComponent”)

适用于所有连接的连接器的刻板印象。

batchApplyStereotype(拱,“连接器”,“GeneralProfile.standardConn”);

一般元素原型应用于所有连接器和港口。

batchApplyStereotype(拱,“组件”,“GeneralProfile.projectElement”);batchApplyStereotype(拱,“连接器”,“GeneralProfile.projectElement”);

设置属性为每个组件。

setProperty (componentSensor“GeneralProfile.projectElement.ID”,“001”);setProperty (componentSensor“GeneralProfile.projectElement.Description”,“中央单位对所有传感器”);setProperty (componentSensor“GeneralProfile.physicalComponent.Cost”,“200”);setProperty (componentSensor“GeneralProfile.physicalComponent.Weight”,“450”);setProperty (componentPlanning“GeneralProfile.projectElement.ID”,“002”);setProperty (componentPlanning“GeneralProfile.projectElement.Description”,“电脑”计划);setProperty (componentPlanning“GeneralProfile.softwareComponent.develCost”,“20000”);setProperty (componentPlanning“GeneralProfile.softwareComponent.develTime”,“300”);setProperty (componentMotion“GeneralProfile.projectElement.ID”,“003”);setProperty (componentMotion“GeneralProfile.projectElement.Description”,“马达和电动机控制器”);setProperty (componentMotion“GeneralProfile.physicalComponent.Cost”,“4500”);setProperty (componentMotion“GeneralProfile.physicalComponent.Weight”,“2500”);

设置连接的属性是相同的。

连接= [c_sensorData c_motionData c_motionCommand c_Command];k = 1:长度(连接)setProperty(连接(k),“GeneralProfile.standardConn.unitCost”,“0.2”);setProperty(连接(k),“GeneralProfile.standardConn.unitWeight”,“100”);setProperty(连接(k),“GeneralProfile.standardConn.length”,“0.3”);结束

添加层次结构

添加两个组件命名控制器范围运动组件。定义的端口。将组件连接到架构和彼此,一个连接器原型应用。层次架构图中创建了一个额外的详细级别指定组件内部是如何表现的。

motionArch = componentMotion.Architecture;motionController = motionArch.addComponent (“控制器”);controllerPorts = addPort (motionController.Architecture, {“controlIn”,“controlOut”},{“在”,“出”});controllerCompPortIn = motionController.getPort (“controlIn”);controllerCompPortOut = motionController.getPort (“controlOut”);motionScope = motionArch.addComponent (“范围”);scopePorts = addPort (motionScope.Architecture, {“scopeIn”,“scopeOut”},{“在”,“出”});scopeCompPortIn = motionScope.getPort (“scopeIn”);scopeCompPortOut = motionScope.getPort (“scopeOut”);c_planningController =连接(motionPorts (1) controllerCompPortIn);

对于外港连接,数据元素必须被指定。

c_planningScope =连接(scopeCompPortOut motionPorts (2),“DestinationElement”,“旋转”);c_planningConnect =连接(controllerCompPortOut scopeCompPortIn,“GeneralProfile.standardConn”);

保存模型。

model.save

由pressıng安排布局Ctrl + Shift +一个或者使用这个命令。

金宝appSimulink.BlockDiagram.arrangeSystem (“mobileRobotAPI /运动”);

创建模型参考

模型引用可以帮助你组织大型模型层级和定义体系结构或行为一旦你可以重用。当一个组件引用另一个模型,任何现有的端口组件被删除,和港口存在的模型会出现在组件引用。

创建一个新的系统作曲家模型。转换控制器组件到组件引用新模型的引用。添加额外的端口控制器组件,您必须更新参考模型“mobileMotion”

referenceModel = systemcomposer.createModel (“mobileMotion”);referenceArch = referenceModel.Architecture;newComponents = addComponent (referenceArch,“陀螺”);referenceModel。保存linkToModel (motionController,“mobileMotion”);

保存模型。

referenceModel。保存model.save

使不同组件

你可以转换规划组件组件使用一个变体makeVariant函数。原始组件嵌入组件作为一个变体的选择一个可用的变体。你可以设计变体组件内的其他变体的选择和切换活动的选择。变体组件允许您以编程方式选择行为设计的结构模型来执行研究和分析。

[variantComp, choice1] = makeVariant (componentMotion);

添加一个额外的变量选择命名的运动Alt。第二个参数定义了名称和第三个参数定义了标签。标签标识的选择。主动选择控制的标签。

choice2 = addChoice (variantComp, {“MotionAlt”},{“MotionAlt”});

创建必要的端口Alt

motionAltPorts = addPort (choice2.Architecture, {“MotionCommand”,“MotionData”},{“在”,“出”});

做运动Alt活跃的变体。

setActiveChoice (variantComp“MotionAlt”)

由pressıng安排布局Ctrl + Shift +一个或者使用这个命令。

金宝appSimulink.BlockDiagram.arrangeSystem (“mobileRobotAPI /规划”);

保存模型。

model.save

清理

运行此脚本将生成的构件在你再次运行这个示例。

cleanUpArtifacts

更多关于

全部展开

版本历史

介绍了R2021b