主要内容

systemcomposer.arch.BaseComponent

所有组件在建筑模型

描述

一个BaseComponent对象不能建造。要么创建一个systemcomposer.arch.Componentsystemcomposer.arch.VariantComponent对象。的systemcomposer.arch.BaseComponent类是来自systemcomposer.arch.Element

属性

全部展开

组件的名称,指定为一个特征向量。

例子:“newComponent”

数据类型:字符

架构定义了组件结构,指定为一个systemcomposer.arch.Architecture对象。为组件引用不同的体系结构模型,该属性返回一个句柄根体系结构的模型。对于不同的组件,架构是活跃的变体。

架构拥有组件指定为一个systemcomposer.arch.Architecture对象。

组件的输入和输出端口,指定为一个systemcomposer.arch.ComponentPort对象。

架构由组件指定为一个systemcomposer.arch.Architecture对象。

组件端口,指定为数组systemcomposer.arch.ComponentPort对象。参考组件,这个属性是空的。

组件的位置在画布上,指定为一个向量的坐标像素:(左右上角底)

数据类型:

通用模型组件的惟一标识符,指定为一个特征向量。

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

数据类型:字符

独特的外部标识符指定为一个特征向量。外部ID是保存的寿命模型组件,并通过所有操作,维护UUID

数据类型:字符

父系统作曲家™组件模型,指定为一个systemcomposer.arch.Model对象。

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

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

数据类型:

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

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

数据类型:

对象的功能

getProperty 得到属性值对应于原型应用于元素
setProperty 设置属性值对应于原型应用于元素
getPropertyValue 建筑的属性值
getEvaluatedPropertyValue 从元素的属性评估值
getStereotypeProperties 让原型属性名的元素
applyStereotype 应用原型架构模型元素
getStereotypes 得到原型应用于元素的建筑模型
removeStereotype 从模型元素删除刻板印象
isProtected 发现如果组件参考模型是保护
isReference 发现如果组件引用到另一个模型
连接 创建架构模型连接
getPort 获得组件的端口
hasStereotype 找到原型应用如果元素
hasProperty 发现如果元素属性
getEvaluatedParameterValue 从元素得到评估值的参数
getParameterNames 得到参数名称的元素
getParameterValue 得到参数的值
setParameterValue 设置参数值
setUnit 在参数值设置单位
resetParameterToDefault 重置在组件参数默认值
摧毁 删除模型元素

例子

全部折叠

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

构建模型

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

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

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

模型= 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

更多关于

全部展开

版本历史

介绍了R2019b