systemcomposer.analysis.ConnectorInstance
分析实例中的连接器
说明
一个 ConnectorInstance
对象代表一个连接器的实例。
创建对象
使用 instantiate
函数创建一个架构实例。
instance = instantiate(model.Architecture,'LatencyProfile','NewInstance', ... 'Function',@calculateLatency,'Arguments','3','Strict',true, ... 'NormalizeUnits',false,'Direction','PreOrder')
属性
实例名称,指定为字符向量。
示例: 'NewInstance'
数据类型: char
包含连接器的组件,指定为 systemcomposer.analysis.ComponentInstance
对象。
连接器实例的端口,指定为 systemcomposer.analysis.PortInstance
对象数组。
源端口实例,指定为 systemcomposer.analysis.PortInstance
对象。
指定为 systemcomposer.analysis.PortInstance
对象的目标端口实例。
设计模型中连接器的引用,指定为 systemcomposer.arch.Connector
或 systemcomposer.arch.PhysicalConnector
对象。
连接器的限定名称,指定为 '<PathToSourceComponent>:<PortDirection>-><PathToDestinationComponent>:<PortDirection>'
形式的字符向量。
示例: 'model2:In->model2/Component:In'
数据类型: char
对象函数
getValue | 从元素实例中获取属性值 |
setValue | 为元素实例设置属性值 |
hasValue | 查找元素实例是否具有属性值 |
isArchitecture | 查找实例是否为架构实例 |
isComponent | 查找实例是否为组件实例 |
isConnector | 查找实例是否为连接器实例 |
isPort | 查找实例是否为端口实例 |
lookup | 搜索架构元素 |
示例
为布线有延迟的系统创建分析实例。使用的材料有铜、光纤和 Wi-Fi®。
使用构造型和属性创建延迟配置文件
创建一个 System Composer™ 配置文件,其中包含基础、连接器、组件和端口构造型。根据分析需要,为每个构造型添加带有默认值的属性。
profile = systemcomposer.profile.Profile.createProfile("LatencyProfileC");
添加带有属性的基本构造型。
latencybase = profile.addStereotype("LatencyBase"); latencybase.addProperty("latency",Type="double"); latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
添加一个带有属性的连接器构造型。
connLatency = profile.addStereotype("ConnectorLatency",... Parent="LatencyProfileC.LatencyBase"); connLatency.addProperty("secure",Type="boolean",DefaultValue="true"); connLatency.addProperty("linkDistance",Type="double");
添加带有属性的组件构造型。
nodeLatency = profile.addStereotype("NodeLatency",... Parent="LatencyProfileC.LatencyBase"); nodeLatency.addProperty("resources",Type="double",DefaultValue="1");
添加带有属性的端口构造型。
portLatency = profile.addStereotype("PortLatency",... Parent="LatencyProfileC.LatencyBase"); portLatency.addProperty("queueDepth",Type="double",DefaultValue="4.29"); portLatency.addProperty("dummy",Type="int32");
使用分析函数实例化
创建新模型并应用配置文件。在模型中创建组件、端口和连接。对模型元素应用构造型。最后,使用分析函数进行实例化。
model = systemcomposer.createModel("archModel"); systemcomposer.openModel("archModel")
ans = Model with properties: Name: 'archModel' SimulinkHandle: 153.0012 Architecture: [1×1 systemcomposer.arch.Architecture] Profiles: [0×0 systemcomposer.profile.Profile] InterfaceDictionary: [1×1 systemcomposer.interface.Dictionary] Views: [0×0 systemcomposer.view.View] Interactions: [0×0 systemcomposer.interaction.Interaction]
arch = model.Architecture;
将配置文件应用到模型。
model.applyProfile("LatencyProfileC");
创建组件、端口和连接。
componentSensor = addComponent(arch,"Sensor"); sensorPorts = addPort(componentSensor.Architecture,{'MotionData','SensorPower'},{'in','out'}); componentPlanning = addComponent(arch,"Planning"); planningPorts = addPort(componentPlanning.Architecture,... {'Command','SensorPower','MotionCommand'},... {'in','in','out'}); componentMotion = addComponent(arch,"Motion"); motionPorts = addPort(componentMotion.Architecture,... {'MotionCommand','MotionData'},{'in','out'}); c_sensorData = connect(arch,componentSensor,componentPlanning); c_motionData = connect(arch,componentMotion,componentSensor); c_motionCommand = connect(arch,componentPlanning,componentMotion);
清理画布。
Simulink.BlockDiagram.arrangeSystem("archModel");
对模型元素批量应用构造型。
batchApplyStereotype(arch,"Component","LatencyProfileC.NodeLatency"); batchApplyStereotype(arch,"Port","LatencyProfileC.PortLatency"); batchApplyStereotype(arch,"Connector","LatencyProfileC.ConnectorLatency");
使用分析函数进行实例化。
instance = instantiate(model.Architecture,"LatencyProfileC","NewInstance",... Function=@calculateLatency,Arguments="3", ... Strict=true,NormalizeUnits=false,Direction="PreOrder")
instance = ArchitectureInstance with properties: Specification: [1×1 systemcomposer.arch.Architecture] IsStrict: 1 NormalizeUnits: 0 AnalysisFunction: @calculateLatency AnalysisDirection: PreOrder AnalysisArguments: '3' ImmediateUpdate: 0 listenerFnc: [] Components: [1×3 systemcomposer.analysis.ComponentInstance] Ports: [0×0 systemcomposer.analysis.PortInstance] Connectors: [1×3 systemcomposer.analysis.ConnectorInstance] Parameters: [0×0 systemcomposer.analysis.InstanceParameter] Name: 'NewInstance'
检查组件、端口和连接器实例
从组件、端口和连接器实例中获取属性。
defaultResources = instance.Components(1).getValue("LatencyProfileC.NodeLatency.resources")
defaultResources = 1
defaultSecure = instance.Connectors(1).getValue("LatencyProfileC.ConnectorLatency.secure")
defaultSecure = logical
1
defaultQueueDepth = instance.Components(1).Ports(1).getValue("LatencyProfileC.PortLatency.queueDepth")
defaultQueueDepth = 4.2900
概述
将典型的汽车电气系统建模为架构模型,并运行基本分析。模型中的元素可大致分为源或负载两类。源和负载的各种属性是作为构造型的一部分设置的。此示例使用规范 API 的 iterate
方法遍历模型的每个元素,并使用构造型属性运行分析。
模型结构
发电机在发动机运转时为蓄电池充电。蓄电池和发电机支持车辆的电力负载,如 ECU、收音机和车身控制装置。电感负载(如电机和其他线圈)已定义了 InRushCurrent
构造型属性。根据为每个组件设置的属性,执行以下分析:
KeyOffLoad
合计。KeyOffLoad
放电 30% 所需的天数。CrankingInRush
总电流。Cranking
总电流。根据蓄电池冷启动安培数 (CCA),蓄电池在 0°F 时启动车辆的能力。放电时间根据 Puekert 系数 (k) 计算得出,该系数描述了放电速率与电池可用容量之间的关系。
加载模型并运行分析
archModel = systemcomposer.loadModel('scExampleAutomotiveElectricalSystemAnalysis');
实例化电池选型类,该类由分析函数使用,用于存储分析结果。
objcomputeBatterySizing = computeBatterySizing;
使用迭代器运行分析。
archModel.iterate('Topdown',@computeLoad,objcomputeBatterySizing)
显示分析结果。
objcomputeBatterySizing.displayResults
Total KeyOffLoad: 158.708 mA Number of days required for KeyOffLoad to discharge 30% of battery: 55.789. Total CrankingInRush current: 70 A Total Cranking current: 104 A CCA of the specified battery is sufficient to start the car at 0 F.
ans = computeBatterySizing with properties: totalCrankingInrushCurrent: 70 totalCrankingCurrent: 104 totalAccesoriesCurrent: 71.6667 totalKeyOffLoad: 158.7080 batteryCCA: 500 batteryCapacity: 850 puekertcoefficient: 1.2000
关闭模型
bdclose('scExampleAutomotiveElectricalSystemAnalysis');
详细信息
术语 | 定义 | 应用 | 更多信息 |
---|---|---|---|
分析 | 静态分析分析系统结构,针对某些特性对架构进行定量评估。静态分析使用分析函数以及系统模型中捕获的属性和参数的参数值。 | 使用分析计算系统的总体可靠性、质量卷积、性能或热特性,或执行大小、重量和功率 (SWaP) 分析以提高效率。 | |
分析函数 | 分析函数是一个 MATLAB® 函数,它使用模型实例中每个元素的属性以及组件和架构层级的实例特定参数计算评估架构所需的值。 | 使用分析函数计算分析结果。 | |
实例模型 | 实例模型是实例的集合。 | 您可以根据模型的更改更新实例模型,但实例模型不会根据活动变体或模型引用的更改而更新。您可以使用保存在 | 运行分析函数 |
实例 | 实例是架构模型元素在给定时间点上的具体体现。 | 实例会冻结实例模型中组件的活动变体或模型引用。 | 创建用于分析的模型实例 |
术语 | 定义 | 应用 | 更多信息 |
---|---|---|---|
架构 | System Composer 架构代表由组件组成的系统,以及这些组件在结构上和行为上如何相互关联。 | 不同类型的架构描述系统的不同方面。您可以使用视图来可视化架构中的组件子集。您可以使用参数编辑器在架构层级上定义参数。 | |
根 | 根位于架构层次结构的顶层。根架构的边界由围绕相关系统的架构端口定义。 | 根架构的系统边界包围着您的架构模型。您可以添加架构端口来定义跨边界接口。 | |
模型 | System Composer 模型是包含架构信息的文件,涵盖组件、端口、连接器、接口和行为等信息。 | 对模型执行操作,包括提取根级架构、应用配置文件、链接接口数据字典或从模型架构生成实例。System Composer 模型存储为 SLX 文件。 | 创建带接口和需求链接的架构模型 |
组件 | 组件是系统中可替换的部分,用于在架构环境中实现明确的函数。组件定义架构元素,例如函数、另一个系统、硬件、软件或其他概念实体。组件也可以是子系统或子函数。 | 组件以模块的形式表示,是架构模型的一部分,并且可以分离成可重用的工件。使用接口编辑器通过端口接口在组件之间传输信息,使用参数编辑器传输参数。 | |
端口 | 端口是组件或架构上的节点,表示与其环境的交互点。通过端口,信息可以流向其他组件或系统,或者从其他组件或系统流入。 | 组件端口是组件上与其他组件之间的交互点。架构端口是系统边界上的端口,无论该边界是在组件内还是在整体架构模型内。根架构具有由其端口定义的边界。 | |
连接器 | 连接器是提供端口之间连接的线路。连接器描述信息如何在组件或架构之间流动。 | 通过连接器,两个组件可以进行交互,而无需定义交互的性质。在端口上设置接口来定义组件之间的交互方式。 |
版本历史记录
在 R2019a 中推出
另请参阅
工具
函数
instantiate
|iterate
|lookup
|save
|update
|refresh
|systemcomposer.analysis.loadInstance
|systemcomposer.analysis.deleteInstance
|getValue
|setValue
|hasValue
|getParameter
|getEvaluatedParameterValue
|getParameterNames
|getParameterValue
|setParameterValue
|isArchitecture
|isComponent
|isConnector
|isPort
|getQualifiedName
对象
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)