主要内容

systemcomposer.interface.DataElement

数据元素的数据接口

描述

一个DataElement对象表示一个数据元素的数据接口。

创建

创建一个数据元素。

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

属性

全部展开

父数据接口的数据元素,指定为一个systemcomposer.interface.DataInterface对象。

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

例子:“newElement”

数据类型:字符|字符串

类型的数据元素,指定为一个systemcomposer.interface.DataInterfacesystemcomposer.ValueType对象。

通用数据元素的惟一标识符,指定为一个特征向量。

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

数据类型:字符

独特的外部标识符指定为一个特征向量。外部ID保存寿命的数据元素,通过保存的所有操作UUID

数据类型:字符

对象的功能

setName 为值类型名称、接口或元素
setType 设置共享类型的数据元素
createOwnedType 创建所有类型的数据元素
摧毁 删除模型元素

例子

全部折叠

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

构建模型

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

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

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

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

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

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

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

dictionary.save

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

添加组件、端口和连接。设置数据接口端口,稍后您将连接。

componentSensor = addComponent(拱门,“传感器”);sensorPorts = addPort (componentSensor.Architecture, {“MotionData”,“SensorData”},{“在”,“出”});sensorPorts (2) .setInterface(接口)componentPlanning = addComponent(拱门,“规划”);planningPorts = addPort (componentPlanning.Architecture, {“命令”,“SensorData1”,“MotionCommand”},{“在”,“在”,“出”});planningPorts (2) .setInterface(接口)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

打开模型。

systemcomposer.openModel (“mobileRobotAPI”);

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

万博1manbetxSimulink.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“长度”,“类型”,“双”,“单位”,“米”);

保存配置文件

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 +一个或者使用这个命令。

万博1manbetxSimulink.BlockDiagram.arrangeSystem (“mobileRobotAPI /运动”);

创建模型参考

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

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

referenceModel = systemcomposer.createModel (“mobileSensor”);referenceArch = referenceModel.Architecture;newComponents = addComponent (referenceArch,“ElectricSensor”);linkDictionary (referenceModel“SensorInterfaces.sldd”);referenceModel。保存linkToModel (componentSensor,“mobileSensor”);

一个原型应用于参考模型的体系结构和组件关联。

referenceModel.applyProfile (“GeneralProfile”);referenceArch.applyStereotype (“GeneralProfile.softwareComponent”);batchApplyStereotype (referenceArch“组件”,“GeneralProfile.projectElement”)

添加端口和连接组件的引用。

sensorPorts = addPort (componentSensor.Architecture, {“MotionData”,“SensorData”},{“在”,“出”});sensorPorts (2) .setInterface(接口)连接(拱、componentSensor componentPlanning,“规则”,“接口”);连接(拱门,componentMotion componentSensor);

保存模型。

referenceModel。保存model.save

使不同组件

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

[variantComp, choice1] = makeVariant (componentPlanning);

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

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

创建必要的端口上PlanningAlt

setActiveChoice (variantComp choice2) planningAltPorts = addPort (choice2.Architecture, {“命令”,“SensorData1”,“MotionCommand”},{“在”,“在”,“出”});planningAltPorts (2) .setInterface(接口)

使PlanningAlt活跃的变体。

setActiveChoice (variantComp“PlanningAlt”)

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

万博1manbetxSimulink.BlockDiagram.arrangeSystem (“mobileRobotAPI /规划”);

保存模型。

model.save

清理

取消这个代码并运行它清理的工件由这个例子。

% bdclose (“mobileRobotAPI”)% bdclose (“mobileSensor”)% 万博1manbetxSimulink.data.dictionary.closeAll% systemcomposer.profile.Profile.closeAll%删除(“Profile.xml”)%删除(“SensorInterfaces.sldd”)

更多关于

全部展开

介绍了R2021b