主要内容

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

updatePosition

根据目标端口更新适配器的位置

自 R2026a 起

    说明

    updatePosition(adapter,TargetPort=target) 根据目标端口 target 更新由 adapter 指定的适配器的位置。

    示例

    示例

    全部折叠

    在 System Composer™ 中创建一个适配器,并将其连接到四个组件。

    创建模型并获取根架构。

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

    创建四个新组件。

    names = ["Component1","Component2","Component3","Component4"];
    newComponents = addComponent(rootArch,names);

    为组件添加端口。

    comp1 = getComponent(rootArch,"Component1");
    comp2 = getComponent(rootArch,"Component2");
    comp3 = getComponent(rootArch,"Component3");
    comp4 = getComponent(rootArch,"Component4");
    outPort1 = addPort(comp1.Architecture,"p1","out");
    outPort2 = addPort(comp2.Architecture,"p2","out");
    inPort1 = addPort(comp3.Architecture,"p3","in");
    inPort2 = addPort(comp4.Architecture,"p4","in");

    提取组件端口。

    srcPort1 = getPort(comp1,"p1");
    srcPort2 = getPort(comp2,"p2");
    destPort1 = getPort(comp3,"p3");
    destPort2 = getPort(comp4,"p4");

    创建一个适配器。

    adapter = rootArch.addAdapter(InputName=["p1","p2"],OutputName=["p3"]);

    将适配器连接到前三个组件上。

    adapter.connectTo(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort1]);

    改进模型布局。

    Simulink.BlockDiagram.arrangeSystem("archModel")

    调整适配器的位置,以便连接到第四个组件。

    adapter.updatePosition(TargetPort=destPort2)

    改进模型布局。

    Simulink.BlockDiagram.arrangeSystem("archModel")

    输入参数

    全部折叠

    适配器,指定为 systemcomposer.arch.Adapter 对象。

    用于连接适配器输出的目标端口,指定为数据输入 systemcomposer.arch.ComponentPort 对象或数据输出 systemcomposer.arch.ArchitecturePort 对象。

    示例: adapter.updatePosition(TargetPort=destPort2)

    详细信息

    全部折叠

    版本历史记录

    在 R2026a 中推出