主要内容

systemcomposer.arch.Architecture

建筑模型

描述

体系结构对象代表作曲家™系统的体系结构模型。这个类是来自systemcomposer.arch.Element

创建

创建一个模型,得到根架构。

模型= systemcomposer.createModel (“archModel”);拱= get(模型,“架构”)

属性

全部展开

建筑名称,指定为一个特征向量。建筑的名字是源自父组件架构所属或模型的名字。

例子:“archModel”

数据类型:字符

定义类型的架构,指定为作文,行为,或视图

数据类型:枚举

父组件拥有建筑、指定为一个systemcomposer.arch.Component对象。

子组件的体系结构中,指定为数组systemcomposer.arch.Component对象。

架构端口,指定为数组systemcomposer.arch.ArchitecturePort对象。

连接器连接子组件的体系结构,指定为数组systemcomposer.arch.Connectorsystemcomposer.arch.PhysicalConnector对象。

通用架构的惟一标识符,指定为一个特征向量。

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

数据类型:字符

独特的外部标识符指定为一个特征向量。外部ID是保存在体系结构的寿命和保存的所有操作UUID

数据类型:字符

父系统作曲家的模型架构,指定为一个systemcomposer.arch.Model对象。

金宝app®处理的架构,指定为一个。这个属性是必需的几个模型相关的工作流程和使用金宝app金宝app仿真软件需求™api。

例子:处理=得到(对象,“SimulinkHan金宝appdle”)

数据类型:

金宝app仿真软件处理的作曲家父系统模型架构,指定为一个。这个属性是必需的几个模型相关的工作流程和使用金宝app金宝app仿真软件的需求api。

例子:处理=得到(对象,“SimulinkMod金宝appelHandle”)

数据类型:

对象的功能

addComponent 添加组件体系结构
addVariantComponent 添加不同组件体系结构
addPort 增加港口体系结构
连接 创建架构模型连接
applyStereotype 应用原型架构模型元素
getStereotypes 得到原型应用于元素的建筑模型
removeStereotype 从模型元素删除刻板印象
batchApplyStereotype 对所有元素在建筑应用原型
迭代 遍历模型元素
实例化 从规范创建分析实例
setProperty 设置属性值对应于原型应用于元素
getProperty 得到属性值对应于原型应用于元素
getPropertyValue 建筑的属性值
getEvaluatedPropertyValue 从组件的属性评估值
getStereotypeProperties 让原型属性名的元素
removeProfile 删除配置文件从模型
applyProfile 概要文件应用到模型
hasStereotype 找到原型应用如果元素
hasProperty 发现如果元素属性

例子

全部折叠

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

构建模型

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

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

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

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

金宝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“长度”,“类型”,“双”,“单位”,“米”);

保存配置文件

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 /运动”);

创建模型参考

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

创建一个新的系统作曲家模型。转换传感器组件到组件引用新模型的引用。添加额外的端口传感器组件,您必须更新参考模型“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 +一个或者使用这个命令。

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

保存模型。

model.save

清理

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

% bdclose (“mobileRobotAPI”)% bdclose (“mobileSensor”)% 金宝appSimulink.data.dictionary.closeAll% systemcomposer.profile.Profile.closeAll%删除(“Profile.xml”)%删除(“SensorInterfaces.sldd”)

更多关于

全部展开

介绍了R2019a