主要内容

systemcomposer.analysis.ComponentInstance

Class that represents component in analysis instance

    描述

    TheComponentInstanceclass represents an instance of a component.

    Creation

    创建一个体系结构的实例。

    实例=实例(model.Architecture,'LatencyProfile','NewInstance',...'Function',@calculatelatency,'Arguments','3','Strict',true,...“标准化”,false,'方向','PreOrder')

    Properties

    展开全部

    Name of instance, specified as a character vector.

    例子:'NewInstance'

    Data Types:char

    Child components of instance, specified as an array ofsystemcomposer.analysis.ComponentInstanceobjects within the architecture.

    端口of component instance, specified as an array ofSystemComposer.Analysis.PORTINSTANCEobjects.

    Connectors in component instance, connecting child components, specified as an array ofsystemcomposer.analysis.ConnectorInstanceobjects.

    Parent of the component, specified as aSystemComposer.Analysis.architectuctInstanceobject.

    Reference to component in design model, specified as asystemcomposer.arch.Componentobject.

    Object Functions

    getValue 从元素实例的属性值
    setValue 元素实例的属性设置值
    hasValue Find if element instance has property value
    简典 Find if instance is architecture instance
    isComponent 查找实例是组件实例
    isConnector Find if instance is connector instance
    isPort Find if instance is port instance

    例子

    collapse all

    This example shows an instantiation for analysis for a system with latency in its wiring. The materials used are copper, fiber, and WiFi.

    Create a Latency Profile with Stereotypes and Properties

    Create a System Composer profile with a base, connector, component, and port stereotype. Add properties with default values to each stereotype as needed for analysis.

    profile = systemcomposer.profile.Profile.createProfile('LatencyProfile');% Add base stereotype with propertieslatencybase = profile.addStereotype('LatencyBase');latencybase.addproperty('latency','类型','double');latencybase.addproperty(“塔尔ate','类型','double','默认值','10');% Add connector stereotype with propertiesconnLatency = profile.addStereotype('ConnectorLatency','Parent',...'LatencyProfile.LatencyBase');connLatency.addProperty('secure','类型',“布尔人”,'默认值','true');connLatency.addProperty('linkDistance','类型','double');%添加具有属性的组件刻板印象nodeLatency = profile.addStereotype('NodeLatency','Parent',...'LatencyProfile.LatencyBase');nodelatency.addproperty('resources','类型','double','默认值','1');% Add port stereotype with propertiesportLatency = profile.addStereotype('PortLatency','Parent',...'LatencyProfile.LatencyBase');portLatency.addProperty('queuedepth','类型','double','默认值','4.29');portLatency.addProperty('假','类型','int32');

    使用分析功能实例化

    Create a new model and apply the profile. Create components, ports, and connections in the model. Apply stereotypes to the model elements. Finally, instantiate using the analysis function.

    model = systemcomposer.createModel('archModel',true);% Create new modelarch = model.Architecture; model.applyProfile('LatencyProfile');%将轮廓应用于模型% Create components, ports, and connections组件= AddComponent(Arch,{'Sensor','Planning','Motion'});sensorports = addport(组件(1).architecture,{'MotionData','SensorData'},{'in','out'});planningPorts = addPort(components(2).Architecture,{'SensorData','MotionCommand'},{'in','out'});motionPorts = addPort(components(3).Architecture,{'MotionCommand','MotionData'},{'in','out'});c_sensordata = connect(Arch,组件(1),组件(2));c_motiondata = connect(Arch,组件(3),组件(1));C_MotionCommand = Connect(Arch,组件(2),组件(3));% Clean up canvasSimulink.BlockDiagram.arrangeSystem('archModel');% Batch apply stereotypes to model elementsbatchApplyStereotype(arch,'Component','LatencyProfile.NodeLatency');batchApplyStereotype(arch,'Port','LatencyProfile.PortLatency');batchApplyStereotype(arch,'Connector','LatencyProfile.ConnectorLatency');%使用分析功能实例化实例=实例(model.Architecture,'LatencyProfile','NewInstance',...'Function',@calculatelatency,'Arguments','3','Strict',true,...“标准化”,false,'方向','PreOrder')
    instance = ArchitectureInstance with properties: Specification: [1x1 systemcomposer.arch.Architecture] IsStrict: 1 NormalizeUnits: 0 AnalysisFunction: @calculateLatency AnalysisDirection: PreOrder AnalysisArguments: '3' ImmediateUpdate: 0 Components: [1x3 systemcomposer.analysis.ComponentInstance] Ports: [0x0 systemcomposer.analysis.PortInstance] Connectors: [1x3 systemcomposer.analysis.ConnectorInstance] Name: 'NewInstance'

    Inspect Component, Port, and Connector Instances

    Get properties from component, port, and connector instances.

    defaultresources = instance.components(1).getValue('LatencyProfile.Nodelatency.Resources')
    defaultResources = 1
    defaultsecure = instance.connectors(1).getValue('LatencyProfile.ConnectorLatency.secure')
    defaultSecure =logical1
    defaultQueueDepth = instance.Components(1).Ports(1).getValue('litencyProfile.portlatency.queuedepth')
    defaultQueueDepth = 4.2900

    Clean Up

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

    % bdclose('archModel')%systemcomposer.profile.profile.closeall

    Overview

    This example shows how to model a typical automotive electrical system as an architectural model and run primitive analysis. The elements in the model can be broadly grouped as either source or load. Various properties of the sources and loads are set as part of the stereotype. The example uses theiteratemethod of the specification API to iterate through each element of the model and run analysis using the stereotype properties.

    Structure of the Model

    发动机运行时,发电机为电池充电。电池以及发电机支持车辆中的电气负载,例如ECU,无线电和车身控制。万博1manbetx电感载荷等电动机和其他线圈具有InRushCurrentstereotype property defined. Based on the properties set on each component, the following analyses are performed:

    • 全部的keyOffload.

    • Number of days required forkeyOffloadto discharge 30% of the battery.

    • 全部的曲柄当前的。

    • 全部的Cranking当前的。

    • Ability of the battery to start the vehicle at 0°F based on the battery cold cranking amps (CCA). The discharge time is computed based on Puekert coefficient (k), which describes the relationship between the rate of discharge and the available capacity of the battery.

    加载模型并运行分析

    archModel = systemcomposer.openModel('scExampleAutomotiveElectricalSystemAnalysis');% Instantiate battery sizing class used by the analysis function to store% analysis results.objcomputeBatterysized = ComputeBatterysized;% Run the analysis using the iterator.archModel.iterate('Topdown',@computeload,objcomputeBatterysizing);% Display analysis results.objcomputeBatterySizing.displayResults;
    全部的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 specifed battery is sufficient to start the car at 0 F.

    关闭模型

    bdclose('scExampleAutomotiveElectricalSystemAnalysis');

    More About

    展开全部

    Introduced in R2019a