主要内容

本页采用了机器翻译。点击此处可查看英文原文。

systemcomposer.arch.PortElement

System Composer 模型中的端口元素

自 R2026a 起

    说明

    PortElement 类表示 System Composer™ 端口元素。该类派生自 systemcomposer.arch.Element

    创建对象

    通过将具有层次结构的接口分配给端口,创建一个 systemcomposer.arch.PortElement 对象。使用 systemcomposer.arch.ArchitecturePort 对象的 PortElements 属性访问端口元素。

    属性

    全部展开

    端口元素的名称,指定为字符向量。

    示例: 'portElement'

    数据类型: char

    与端口元素关联的接口元素,指定为 systemcomposer.interface.DataElementsystemcomposer.interface.FunctionElement 对象。

    该端口元素所拥有的端口元素,指定为 systemcomposer.arch.PortElement 对象数组。

    所属端口或端口元素,指定为 systemcomposer.arch.ArchitecturePortsystemcomposer.arch.PortElement 对象。

    父级 System Composer 模型,指定为 systemcomposer.arch.Model 对象。

    Simulink® 句柄,指定为双精度类型。

    此属性对于多个 Simulink 工作流以及使用 Requirements Toolbox™ 编程接口而言是必不可少的。

    示例: handle = get(object,'SimulinkHandle')

    数据类型: double

    Simulink 父级 System Composer 模型的句柄,指定为双精度数值。

    此属性对于多个 Simulink 工作流以及使用 Requirements Toolbox 编程接口而言是必不可少的。

    示例: handle = get(object,'SimulinkModelHandle')

    数据类型: double

    唯一外部标识符,指定为字符向量。外部 ID 在元素的整个生命周期以及所有保留 UUID 的操作中都会被保留。

    数据类型: char

    统一唯一标识符,指定为字符向量

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

    数据类型: char

    对象函数

    getSubElement按名称获取子端口元素
    getQualifiedName获取模型元素的限定名称
    destroy移除模型元素

    示例

    全部折叠

    创建模型并获取根架构。

    model = systemcomposer.createModel("archModel");
    systemcomposer.openModel("archModel");
    rootArch = get(model,"Architecture");

    添加一个组件,并为组件添加一个端口。

    newComponent = addComponent(rootArch,"newComponent");
    newPort = addPort(newComponent.Architecture,"newPort","in");

    添加一个包含一个数据元素的第一个数据接口。

    newInterface = addInterface(model.InterfaceDictionary,"newInterface");
    newElement = addElement(newInterface,"newElement",DataType="double");

    添加第二个数据接口,并包含第二个数据元素。

    newInterface2 = addInterface(model.InterfaceDictionary,"newInterface2");
    newElement2 = addElement(newInterface2,"newElement2",DataType="double");

    使用第二个数据接口输入第一个数据元素。

    newElement.setType(newInterface2)

    在该端口上设置第一个接口。

    setInterface(newPort,newInterface)

    从端口元素访问数据元素。

    portElement = getPortElement(newPort,'newElement')
    portElement = 
    
      PortElement with properties:
    
                       Name: 'newElement'
                     Parent: [1×1 systemcomposer.arch.ArchitecturePort]
                SubElements: [1×1 systemcomposer.arch.PortElement]
           InterfaceElement: [1×1 systemcomposer.interface.DataElement]
                      Model: [1×1 systemcomposer.arch.Model]
             SimulinkHandle: -1
        SimulinkModelHandle: 149.0002
                       UUID: '40b38418-76b2-4a96-9da7-d6c6f237cf56'
                ExternalUID: ''

    获取第一个端口元素的子节点。

    childElement = getSubElement(portElement,'newElement2')
    childElement = 
    
      PortElement with properties:
    
                       Name: 'newElement2'
                     Parent: [1×1 systemcomposer.arch.PortElement]
                SubElements: []
           InterfaceElement: [1×1 systemcomposer.interface.DataElement]
                      Model: [1×1 systemcomposer.arch.Model]
             SimulinkHandle: -1
        SimulinkModelHandle: 149.0001
                       UUID: 'f37144f3-6db3-4cfc-ac0a-833bfcf0c282'
                ExternalUID: ''

    详细信息

    全部展开

    版本历史记录

    在 R2026a 中推出