Main Content

systemcomposer.arch.PhysicalConnector

物理端口之间的连接器

Description

一个物理渠道对象代表系统Composer™模型之间物理端口之间的连接器。此类从systemcomposer.arch.baseconnector。This class is derived fromSystemComposer.arch.element

创建

使用连接功能。

physConns = connect(architecture,physPortsA,physPortsB)

特性

expand all

姓名of connector, specified as a character vector.

Example:'newConnector'

数据类型:char

一个rchitecture that owns connector, specified as aSystemComposer.arch.architectureobject.

通用唯一标识符为了model connector, specified as a character vector.

Example:'91D5DE2C-B14C-4C76-A5D6-5DDDD0037C52DF'

数据类型:char

唯一的外部标识符,,,,specified as a character vector. The external ID is preserved over the lifespan of the model connector and through all operations that preserve theUUID

数据类型:char

家长系统作曲家的连接器模型,指定为systemcomposer.arch.Modelobject.

金宝app®连接器的手柄,指定为double。此属性对于几个相关的工作流程和使用都是必需的金宝app需求工具箱™蜜蜂。

Example:hander = get(对象,'simu金宝applinkhandle')

数据类型:double

Simulink handle to parent System Composer model of connector, specified as adouble。此属性对于几个相关的工作流程和使用都是必需的金宝app需求工具箱蜜蜂。

Example:hander = get(对象,'simu金宝applinkmodelhandle')

数据类型:double

对象功能

applystereotype 将刻板​​印象应用于架构模型元素
getStereotypes 获取对建筑模型元素的刻板印象
拆卸电脑 从模型元素中删除刻板印象
setProperty 设置对应于应用于元素的刻板印象的属性值
getProperty Get property value corresponding to stereotype applied to element
getPropertyValue Get value of architecture property
getevalidpropertyvalue Get evaluated value of property from element
getStereotypeProperties 在元素上获取刻板印象属性名称
getSourceElement 得到的数据元素选择欺诈的源端口nection
getDestinationElement Gets data elements selected on destination port for connection
hasStereotype Find if element has stereotype applied
Hasproperty Find if element has property
getQualifyName 获取模型元素合格名称
destroy 删除模型元素

Examples

collapse all

Build an architecture model programmatically using System Composer™.

构建模型

To build a model, add a data dictionary with data interfaces, data elements, a value type, and a physical interface, then add components, ports, and connections. Create a profile with stereotypes and properties and then apply those stereotypes to model elements. Assign an owned interface to a port. After the model is built, you can create custom views to focus on specific considerations. You can also query the model to collect different model elements according to criteria you specify.

添加组件,端口,连接和接口

创建模型并提取其体系结构。

model = systemcomposer.createmodel(“ Mobilerobotapi”);Arch = model.Architecture;

创建一个接口数据字典并添加数据接口。将数据元素添加到数据接口。将值类型添加到接口数据字典中。将数据元素的类型分配给值类型。使用物理域类型添加物理接口和物理元素。将数据字典链接到模型。

dictionary = systemcomposer.createDictionary(“ sensorinterfaces.sldd”);interface = dictionary.addInterface("GPSInterface");element = interface.addElement(“信号强度”);valueType = dictionary.Addvaluetype(“ SignalStrengthtype”,,,,Units=“D b”,,,,Description="GPS Signal Strength");element.setType(valueType);物理界面= dictionary.AddphysicalInterface("PhysicalInterface");物理电子= addElement(物理接口,"ElectricalElement",type ="electrical.electrical");linkDictionary(model,“ sensorinterfaces.sldd”);

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

字典

保存模型。

model.save

打开模型。

systemcomposer.openmodel(“ Mobilerobotapi”);

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

一个dd components, ports, and connections. Set the physical interface to the physical ports, which you will connect later.

零件Sensor = addComponent(arch,“传感器”);sensorPorts = addPort(componentSensor.Architecture,{'MotionData',,,,'SensorPower'},{'在',,,,'身体的'});sensorports(2).setInterface(yxulyInterface)componentplanning = addcomponent(拱门,,"Planning");planningports = addport(componentplanning.architecture,{'Command',,,,'SensorPower1',,,,“运动仪”},{'在',,,,'身体的',,,,'out'});planningports(2).setInterface(yxulyInterface)componentMotion = addcomponent(拱门,"Motion");MotionPorts = AddPort(ComponentMotion.Architecture,{“运动仪”,,,,'MotionData'},{'在',,,,'out'});

'MotionData'港口。一个dd an owned data element under the owned data interface. Assign the data element "回转”至a value type with units set todegrees

ownedInterface = motionPorts(2).createInterface(“ datainterface”);ownedelement = ownedinterface.addelement(“回转”);subInterface = ownedElement.createOwnedType(Units="degrees");

查看接口编辑器中的接口。Select the'MotionData'港口on the运动零件。在接口编辑器中,从字典视图端口接口视图

使用接口规则和默认名称规则连接组件。接口规则连接共享相同接口的组件上的端口。默认情况下,名称规则连接共享同名的组件上的端口。

c_sensordata = connect(Arch,ComponentSEnsor,componentplanning,rule =“界面”);c_motionData = connect(arch,componentMotion,componentSensor); c_motionCommand = connect(arch,componentPlanning,componentMotion);

一个dd and Connect Architecture Port

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

archPort = addPort(arch,"Command",,,,“在”);

连接command requires a component port as an argument. Obtain the component port, then connect.

compPort = getPort(componentPlanning,"Command");c_Command = connect(archPort,compPort);

保存模型。

model.save

一个rrange the layout by pressıngCtrl+Shift+A或使用此命令。

金宝appsimulink.blockdiagram.arangesystem(“ Mobilerobotapi”);

Create and Apply Profile with Stereotypes

Profiles are XML files that can be applied to any model. You can add stereotypes with properties to profiles and then populate the properties with specific values. Along with the built-in analysis capabilities of System Composer, stereotypes help you optimize your system for performance, cost, and reliability.

创建个人资料并添加刻板印象

Create a profile.

profile = systemcomposer.createprofile("GeneralProfile");

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

ElemStype = Addstereotype(配置文件,"projectElement");

为不同类型的组件创建刻板印象。您可以根据您的设计需求选择这些类型。

pcompstype = addstereotype(配置文件,“物理组合”,appliesto =“零件”);sCompSType = addStereotype(profile,"softwareComponent",appliesto =“零件”);

为连接创建刻板印象。

sconnstype = addstereotype(配置文件,"standardConn",appliesto ="Connector");

添加属性

一个dd properties to the stereotypes. You can use properties to capture metadata for model elements and analyze nonfunctional requirements. These properties are added to all elements to which the stereotype is applied, in any model that imports the profile.

addProperty(elemSType,'ID',type =“ uint8”);addProperty(elemSType,'描述',type =“细绳”);addProperty(pCompSType,'成本',type ="double",,,,Units=“美元”);addProperty(pCompSType,'Weight',type ="double",,,,Units=“G”);AddProperty(scompstype,“ DEVELCOST”,type ="double",,,,Units=“美元”);AddProperty(scompstype,“ develtime',type ="double",,,,Units=“小时”);addProperty(sConnSType,'unitCost',type ="double"',Units=“美元”);addProperty(sConnSType,“单位重量”,type ="double",,,,Units=“G”);addProperty(sConnSType,'length',type ="double",,,,Units="m");

Save Profile

profile.save;

一个pply Profile to Model

一个pply the profile to the model.

应用程序(模型,"GeneralProfile");

一个pply stereotypes to components. Some components are physical components, while others are software components.

applystereotype(组合规划,“ GeneralProfile.softWareComponent”)applystereotype(compententSensor,"GeneralProfile.physicalComponent")applystereotype(componentMotion,"GeneralProfile.physicalComponent"

一个pply the connector stereotype to all connections.

batchapplystereotype(Arch,'连接器',,,,“ GeneralProfile.StandardConn”);

将一般元素刻板印象应用于所有连接器和端口。

batchapplystereotype(Arch,'零件',,,,“ GeneralProfile.Projectelement”);batchapplystereotype(Arch,'连接器',,,,“ GeneralProfile.Projectelement”);

为每个组件设置属性。

setProperty(componentsensor,'GeneralProfile.projectElement.ID',,,,'001');setProperty(componentsensor,'GeneralProfile.Projectelement.Description',,,,''“所有传感器的中央单元”'');setProperty(componentsensor,'general -profile.physicalcomponent.cost',,,,'200');setProperty(componentsensor,'general -profile.physicalcomponent.ueight',,,,'450');setProperty(componentplanning,'GeneralProfile.projectElement.ID',,,,'002');setProperty(componentplanning,'GeneralProfile.Projectelement.Description',,,,'''Planning computer''');setProperty(componentplanning,'GeneralProfile.softwareComponent.develCost',,,,'20000');setProperty(componentplanning,'general -profile.softwarecomponent.develtime',,,,'300');setProperty(componentMotion,'GeneralProfile.projectElement.ID',,,,'003');setProperty(componentMotion,'GeneralProfile.Projectelement.Description',,,,'''Motor and motor controller''');setProperty(componentMotion,'general -profile.physicalcomponent.cost',,,,'4500');setProperty(componentMotion,'general -profile.physicalcomponent.ueight',,,,'2500');

Set the properties of connections to be identical.

连接ions = [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.Lengths',,,,'0.3');结尾

一个dd Hierarchy

一个dd two components namedControllerand范围在 - 的里面运动零件。Define the ports. Connect the components to the architecture and to each other, applying a connector stereotype. Hierarchy in an architecture diagram creates an additional level of detail that specifies how components behave internally.

MotionArch = ComponentMotion.Architecture;MotionController = MotionArch.AddComponent('控制器');ControllerPorts = AddPort(MotionController.Architecture,{“控制蛋白”,,,,“控制”},{'在',,,,'out'});controllerCompPortIn = motionController.getPort(“控制蛋白”);contranceerCompportout = MotionController.getPort(“控制”);motionsCope = MotionArch.AddComponent('Scope');scopePorts = addPort(motionScope.Architecture,{'scopein',,,,``瞄准''},{'在',,,,'out'});scopecompportin = motionscope.getport('scopein');scopecompportout = motionscope.getport(``瞄准'');c_planningController = connect(motionPorts(1),controllerCompPortIn);

For outport connections, the data element must be specified.

c_planningscope = connect(scopecompportout,Motionports(2),,“目标元素”,,,,“回转”);c_planningConnect = connect(controllerCompportout,scopecompportin,'GeneralProfile.standardConn');

保存模型。

model.save

一个rrange the layout by pressıngCtrl+Shift+A或使用此命令。

金宝appsimulink.blockdiagram.arangesystem('mobileRobotAPI/Motion');

创建模型参考

Model references can help you organize large models hierarchically and define architectures or behaviors once that you can then reuse. When a component references another model, any existing ports on the component are removed, and ports that exist on the referenced model will appear on the component.

Create a new System Composer model. Convert theController组件成一个参考组件,以引用新模型。在Controller零件,,,,you must update the referenced model"mobileMotion"

ReferenceModel = SystemComposer.CreateModel("mobileMotion");referencearch = referencemodel.architecture;newcomponents = addComponent(Referencearch,“陀螺仪”);referencemodel.save linkTomodel(MotionController,,,"mobileMotion");

保存模型。

referenceModel.save model.save

制作变体组件

你可以转换规划零件至a variant component using themakevariant功能。原始组件被嵌入变体组件中,作为可用变体选择之一。您可以在变体组件中设计其他变体选择并切换活动选择。变体组件允许您在架构模型中以编程方式选择行为设计来执行贸易研究和分析。

[variantComp,choice1] = makeVariant(componentMotion);

添加一个名为Motion的其他变体选择一个lt。第二个参数定义了名称,第三个参数定义了标签。标签标识了选择。主动选择由标签控制。

选择2 = addChoice(variantComp,{'MotionAlt'},{'MotionAlt'});

Create the necessary ports on Motion一个lt

motionAltPorts = addPort(choice2.Architecture,{“运动仪”,,,,'MotionData'},{'在',,,,'out'});

Make Motion一个lt活动变体。

setActiveChoice(variantComp,'MotionAlt'

一个rrange the layout by pressıngCtrl+Shift+A或使用此命令。

金宝appsimulink.blockdiagram.arangesystem(“ Mobilerobotapi/计划”);

保存模型。

model.save

清理

Run this script to remove generated artifacts before you run this example again.

cleanUpArtifacts

更多关于

expand all

版本历史记录

Introduced in R2021b