主要内容

systemcomposer.arch.Connector

类,表示端口之间的连接器

描述

连接器类表示端口之间的连接器。这个类派生自systemcomposer.arch.Element

创建

创建一个连接器。

Connector = Connect(架构,出口,Inports)

属性

全部展开

掌握拥有连接器的父体系结构,指定为asystemcomposer.arch.Architecture对象。

连接器的名称,指定为字符向量。

数据类型:字符

作为输出端口的连接源,指定为systemcomposer.arch.architionPort.systemcomposer.arch.componentport.对象。

作为输入端口的连接目的地,指定为systemcomposer.arch.architionPort.systemcomposer.arch.componentport.对象。

模型连接器的通用唯一标识符,指定为字符向量。

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

数据类型:字符

唯一的外部标识符,指定为字符向量。外部ID将在元素的整个生命周期和所有保存uuid.

数据类型:字符

父模型的连接器,指定为asystemcomposer.arch.Model对象。

万博1manbetx用于连接器的Simulink句柄,指定为数值。这个属性对于几个与Simulink相关的工作流和使用Simulink需求api万博1manbetx是必要的。

例子:处理=得到(对象,“SimulinkHan万博1manbetxdle”)

数据类型:

万博1manbetx连接器的父模型的Simulink句柄,指定为一个数值。这个属性对于几个与Simulink相关的工作流和使用Simulink需求api万博1manbetx是必要的。

例子:处理=得到(对象,“SimulinkMod万博1manbetxelHandle”)

数据类型:

对象的功能

ApplyStereotype. 将原型应用到架构模型元素
getstereotypes. 获取应用于架构模型元素的原型
RemovestEthotype. 从模型元素中删除刻板印象
setProperty 设置应用于元素的原型对应的属性值
getProperty. 获取应用于元素的原型对应的属性值
getPropertyValue 获得建筑产权的价值
getEvaluatedPropertyValue 从组件获取属性的评估值
getStereotypeProperties 在元素上获取刻板型属性名称
getSourceElement 获取在用于连接的源端口上选择的信号接口元素
getDestinationElement 获取在目标端口上选择的信号接口元素以进行连接
摧毁 删除模型元素

例子

全部折叠

此示例显示如何使用System Composer™API构建架构模型。

准备工作空间

从工作区中清除所有概要文件。

systemcomposer.profile.Profile.closeAll;

建立一个模型

要构建模型,需要添加一个带有接口和接口元素的数据字典,然后添加组件、端口和连接。在构建模型之后,您可以创建自定义视图来关注特定的关注点。您还可以查询模型,根据您指定的条件收集不同的模型元素。

添加组件、端口和连接

创建模型并提取其架构。

Model = SystemComposer.createModel('mobilerobotapi');arch = model.architecture;

创建数据字典,添加接口。将接口链接到模型。

字典= systemcomposer.createDictionary ('sensorinterfaces.sldd');interface = addinterface(字典,“GPSInterface”);interface.addelement(“质量”);linkDictionary(模型,'sensorinterfaces.sldd');

添加组件、端口和连接。将接口设置为稍后将连接的端口。

组件= addComponent(拱门,{“传感器”'规划'“运动”});SensorPorts = Addport(组件(1).Architecture,{'motiondata'“SensorData”},{“在”“出”});sensorPorts (2) .setInterface(接口);planningPorts = addPort(组件(2)。架构,{“命令”“SensorData1”“MotionCommand”},{“在”“在”“出”});Plannports(2).setInterface(接口);MotionPorts = Addport(组件(3).architecture,{“MotionCommand”'motiondata'},{“在”“出”});

使用接口规则连接组件。此规则在共享相同接口的组件上连接端口。

c_sensordata = connect(arch,组件(1),组件(2),'规则''界面');c_motiondata = connect(arch,组件(3),组件(1));c_motioncommand = connect(arch,组件(2),组件(3));

保存数据字典

将更改保存到数据字典中。

dictionary.save ();

添加并连接架构端口

在架构上添加一个体系结构端口。

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

连接命令需要组件端口作为参数。获取部件端口并连接:

compPort = getPort(组件(2),“命令”);c_Command =连接(archPort compPort);

保存模型。

保存(模型)

打开模型

Open_System(GCS);

通过pressıng安排布局ctrl + shift + a或者使用以下命令:

万博1manbetxSimulink.BlockDiagram.arrangeSystem ('mobilerobotapi');

创建并应用概要文件和原型

概要文件XML.可以应用于任何模型的文件。您可以将带有属性的原型添加到概要文件中,然后用特定的值填充属性。与System Composer的内置分析功能一起,原型可以指导系统的性能、成本和可靠性的优化。

创建概要文件并添加原型

创建配置文件。

profile = systemcomposer.createprofile(“GeneralProfile”);

创建一个适用于所有元素类型的刻板印象:

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

为不同类型的组件创建刻板印象。这些类型由设计需求决定,并取决于您的自由裁量权:

pcompstype = addstereotype(配置文件,'LeatherComponent''适用于''成分');sCompSType = addStereotype(概要文件,'softwarecomponent''适用于''成分');

为连接创建一个模板:

sconnstype = addstereotype(配置文件,'standarconn''适用于'“连接器”);

添加属性

将属性添加到刻板印象。您可以使用属性来捕获模型元素的元数据并分析非功能性要求。在导入配置文件的任何模型中,将这些属性添加到应用刻板印象的所有元素。

addProperty (elemSType“ID”“类型”“uint8”);addProperty (elemSType'描述'“类型”“字符串”);addProperty (pCompSType'成本'“类型”“双”'单位'“美元”);addProperty (pCompSType“重量”“类型”“双”'单位'‘g’);AddProperty(scompstype,'develcost'“类型”“双”'单位'“美元”);AddProperty(scompstype,'develtime'“类型”“双”'单位'“小时”);addProperty (sConnSType'单位成本'“类型”“双”'单位'“美元”);addProperty (sConnSType“unitWeight”“类型”“双”'单位'‘g’);addProperty (sConnSType“长度”“类型”“双”'单位''M');

保存配置文件

保存(配置文件);

将概要文件应用于模型

将概要文件应用到模型:

ApplyProfile(型号,“GeneralProfile”);

将刻板​​印象应用于组件。某些组件是物理组件,其他组件是软件组件。

applyStereotype(组件(2),'GeneralProfile.softwarecomponent')ApplyStereotype(组件(1),'GeneralProfile.physicalComponent')ApplyStereotype(组件(3),'GeneralProfile.physicalComponent'

将连接器刻板印象应用于所有连接:

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

将通用元素原型应用于所有连接器和端口:

batchApplyStereotype(拱,'成分''generalprofile.projectelement');batchApplyStereotype(拱,“连接器”'generalprofile.projectelement');

为每个组件设置属性:

setProperty(组件(1),“GeneralProfile.projectElement.ID”“001”);setProperty(组件(1),“GeneralProfile.projectElement.Description”“‘所有传感器的中央单元’”);setProperty(组件(1),“GeneralProfile.physicalComponent.Cost”“200”);setProperty(组件(1),“GeneralProfile.physicalComponent.Weight”“450”);setProperty(组件(2),“GeneralProfile.projectElement.ID”“002”);setProperty(组件(2),“GeneralProfile.projectElement.Description”“电脑”计划);setProperty(组件(2),“GeneralProfile.softwareComponent.develCost”“20000”);setProperty(组件(2),“GeneralProfile.softwareComponent.develTime”'300');setProperty(组件(3),“GeneralProfile.projectElement.ID”“003”);setProperty(组件(3),“GeneralProfile.projectElement.Description”“电机及电机控制器”);setProperty(组件(3),“GeneralProfile.physicalComponent.Cost”“4500”);setProperty(组件(3),“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 =组件(3).Architecture;motion = motionarch.addcomponent({'控制器'“范围”});ControllerPorts = Addport(Motion(1).architecture,{'Controlin'“controlOut”},{“在”“出”});(1) .getPort (controllerCompPortIn =运动'Controlin');(1) .getPort (controllerCompPortOut =运动“controlOut”);scopeports = Addport(Motion(2).Architecture,{'scopein''Scopeout'},{“在”“出”});scopecompportin = motion(2).getport('scopein');scopecompportout = motion(2).getport('Scopeout');c_planningcontroller = connect(MotionPorts(1),ControllerCompportin);c_planningscope = connect(scopecompportout,motionports(2));c_planningconnect = connect(ControllerCompportout,Scopecompportin,“GeneralProfile.standardConn”);

保存模型。

保存(模型)

通过pressıng安排布局ctrl + shift + a或者使用以下命令:

万博1manbetxSimulink.BlockDiagram.arrangeSystem ('mobilerobotapi / motion');

创建模型引用

模型引用可用于分层组织大型模型,并允许您定义一次架构或行为并重用它。当组件引用另一个模型时,将删除组件上的任何现有端口,并且在组件上会显示引用的模型上存在的端口。

创建一个新的System Composer模型。转换传感器组件到引用组件中以引用新模型。添加其他端口传感器组件,您必须更新引用的模型mobileSensor

newModel = systemcomposer.createModel ('mobilesensor');newArch = newModel.Architecture;newComponents = addComponent (newArch,'电气信徒');保存(newModel);linkToModel(组件(1),'mobilesensor');

将刻板​​印象应用于链接的参考模型的体系结构和组件。

referenceModel = get_param ('mobilesensor''systemcomposermodel');ReferenceModel.applyProfile(“GeneralProfile”);ReferEnceModel.architeUre.applyStereotype('GeneralProfile.softwarecomponent');batchApplyStereotype (referenceModel。架构,'成分''generalprofile.projectelement'

向参考组件添加端口和连接。

SensorPorts = Addport(组件(1).Architecture,{'motiondata'“SensorData”},{“在”“出”});sensorPorts (2) .setInterface(接口)连接(拱、组件(1),(2)组件,'规则''界面');连接(拱门,组件(3),组件(1));

保存模型。

保存(referenceModel)保存(模型)

制作变体组件

你可以转换规划组件转换为变量组件makefariant.功能。原始组件嵌入在变型组件中作为可用变体选择之一。您可以在变体组件中设计其他变体选择并切换活动选择。变体组件允许您在架构模型中以编程方式选择行为设计,以进行贸易研究和分析。

[variantComp, choice1] = makeVariant(组件(2));

添加一个名为策划。第二个参数定义名称,第三个参数定义了标签。标签识别选择。主动选择由标签控制。

choice2 = addChoice (variantComp, {'策略'},{'策略'});

创建所需的端口策划

setActiveChoice(VariantComp,Choice2)Cransaltports = Addport(Choice2.Architecture,{“命令”“SensorData1”“MotionCommand”},{“在”“在”“出”});CannerAltports(2).setInterface(界面);

使策划活性变体。

setActiveChoice (variantComp'策略'

通过pressıng安排布局ctrl + shift + a或者使用以下命令:

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

保存模型。

保存(模型)

清理

取消注释以下代码,并运行以清理由本示例创建的工件:

%bdclose('mobilerobotapi')% bdclose(“mobileSensor”)%s万博1manbetximulink.data.dictionary.closeall.% systemcomposer.profile.Profile.closeAll%删除(“Profile.xml”)%删除('sensorinterfaces.sldd')

更多关于

全部展开

在R2019A介绍