架构模型中的所有端口
一个BasePort
对象不能被构造。创建一个systemcomposer.arch.ArchitecturePort
或者一个systemcomposer.arch.ComponentPort
对象。的systemcomposer.arch.BasePort
类派生自systemcomposer.arch.Element
.
的名字
- - - - - -港口的名字端口的名称,指定为字符向量。
例子:“新港”
数据类型:字符
方向
- - - - - -港口方向“输入”
|“输出”
|“物理”
端口方向,指定为字符向量。
数据类型:字符
父
- - - - - -拥有港口的架构拥有端口的体系结构,指定为systemcomposer.arch.Architecture
对象。
InterfaceName
- - - - - -端口关联的接口名称与端口相关联的接口名称,指定为字符向量。
数据类型:字符
接口
- - - - - -端口关联接口与端口关联的接口,指定为systemcomposer.interface.DataInterface
或systemcomposer。ValueType
对象。
连接器
- - - - - -端口连接器连接
- - - - - -端口是否有连接真正的
或1|假
或0端口是否有连接,指定为逻辑。
数据类型:逻辑
UUID
- - - - - -通用唯一标识符模型端口的通用唯一标识符,指定为字符向量。
例子:91 d5de2c-b14c-4c76-a5d6-5dd0037c52df
数据类型:字符
ExternalUID
- - - - - -独特的外部标识符唯一的外部标识符,指定为字符向量。外部ID在模型端口的整个生命周期和所有保存UUID
.
数据类型:字符
模型
- - - - - -父母模型父System Composer™端口模型,指定为systemcomposer.arch.Model
对象。
万博1manbetxSimulinkHandle
- - - - - -万博1manbetx仿真软件处理万博1manbetx®端口的手柄,指定为双
.这个属性对于几个与Simulink相关的工作流和使用是必要的万博1manbetx万博1manbetx仿真软件需求™api。
例子:处理=得到(对象,“SimulinkHan万博1manbetxdle”)
数据类型:双
万博1manbetxSimulinkModelHandle
- - - - - -万博1manbetx父模型的Simulink句柄万博1manbetxSimulink句柄到父System Composer模型的端口,指定为双
.这个属性对于几个与Simulink相关的工作流和使用是必要的万博1manbetx万博1manbetx仿真软件的需求api。
例子:处理=得到(对象,“SimulinkMod万博1manbetxelHandle”)
数据类型:双
getProperty |
获取应用于元素的原型对应的属性值 |
setProperty |
设置应用于元素的原型对应的属性值 |
getPropertyValue |
获得建筑产权的价值 |
getEvaluatedPropertyValue |
从组件获取属性的评估值 |
getStereotypeProperties |
获取元素上的构造型属性名 |
applyStereotype |
将原型应用到架构模型元素 |
getStereotypes |
获取应用于架构模型元素的原型 |
removeStereotype |
从模型元素中移除原型 |
hasStereotype |
查找元素是否应用了原型 |
hasProperty |
查找元素是否具有属性 |
摧毁 |
删除模型元素 |
使用System Composer™以编程方式构建体系结构模型。
构建模型
要构建模型,请添加具有数据接口、数据元素和值类型的数据字典,然后添加组件、端口和连接。为端口分配一个拥有的接口。在构建模型之后,您可以创建自定义视图来关注特定的注意事项。您还可以查询模型,根据您指定的条件收集不同的模型元素。
添加组件、端口、连接和接口
创建模型并提取其架构。
模型= 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。架构,{“MotionData”,“SensorData”}, {“在”,“出”});sensorPorts(2).setInterface(interface) = addComponent(arch,“规划”);planningPorts = addPort (componentPlanning。架构,{“命令”,“SensorData1”,“MotionCommand”}, {“在”,“在”,“出”});planingports (2).setInterface(interface) = addComponent(arch,“运动”);motionPorts = addPort (componentMotion。架构,{“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文件。您可以将带有属性的原型添加到概要文件中,然后用特定的值填充属性。与System Composer的内置分析功能一起,构造型帮助您优化系统的性能、成本和可靠性。
创建概要文件和添加原型
创建一个概要文件。
形象= 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];为setProperty(connections(k)) = 1:length(connection)“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。架构,{“controlIn”,“controlOut”}, {“在”,“出”});controllerCompPortIn = motionController.getPort (“controlIn”);controllerCompPortOut = motionController.getPort (“controlOut”);motionScope = motionArch.addComponent (“范围”);scopePorts = addPort (motionScope。架构,{“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 /运动”);
创建模型参考
模型引用可以帮助您分层组织大型模型,并定义架构或行为,然后您可以重用。当一个组件引用另一个模型时,该组件上的任何现有端口都将被删除,被引用模型上存在的端口将出现在该组件上。
创建一个新的System Composer模型。转换传感器
组件转换为引用组件以引用新模型。在。上添加其他端口传感器
组件时,您必须更新所引用的模型“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。架构,{“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)架构,{“命令”,“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”)
术语 | 定义 | 应用程序 | 更多的信息 |
---|---|---|---|
体系结构 | 一个System Composer体系结构代表了一个由组件组成的系统,以及它们如何在结构上和行为上相互接口。您可以使用备用视图来表示特定的体系结构。 | 不同类型的体系结构描述了系统的不同方面:
|
组成建筑视觉 |
模型 | System Composer模型是包含架构信息的文件,包括组件、端口、连接器、接口和行为。 | 对模型进行操作:
System Composer模型存储为SLX文件。 |
创建具有接口和需求链接的体系结构模型 |
组件 | 组件是系统中重要的、几乎独立的、可替换的部分,在体系结构的上下文中实现明确的功能。组件定义架构元素,如功能、系统、硬件、软件或其他概念实体。组件也可以是一个子系统或子功能。 | 组件表示为块,它是体系结构模型的一部分,可以分离为可重用的构件。 | 组件 |
港口 | 端口是组件或体系结构上的一个节点,它表示与环境的一个交互点。端口允许信息进出其他部件或系统。 | 有不同类型的端口:
|
港口 |
连接器 | 连接器是在端口之间提供连接的线。连接器描述了信息如何在组件或体系结构之间流动。 | 连接器允许两个组件在不定义交互性质的情况下进行交互。在端口上设置接口以定义组件如何交互。 | 连接 |
systemcomposer.arch.Element
|systemcomposer.arch.ComponentPort
|systemcomposer.arch.ArchitecturePort
|组件
你点击一个链接对应于这个MATLAB命令:
通过在MATLAB命令窗口中输入命令来运行命令。Web浏览器不支持MATLAB命令。万博1manbetx
你也可以从以下列表中选择一个网站:
选择中国网站(中文或英文)以获得最佳网站性能。其他MathWorks国家站点没有针对您所在位置的访问进行优化。