主要内容

connectTo

Connect adapter to architectural elements

Since R2026a

    Description

    connectTo(adapter,Name=Value) connects the adapter specified by adapter to another architectural element using options specified by name-value arguments.

    example

    Examples

    collapse all

    Create and connect an adapter to three components in System Composer™.

    Create a model and get the root architecture.

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

    Create three new components.

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

    Add ports to the components.

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

    Extract the component ports.

    srcPort1 = getPort(comp1,"p1");
    srcPort2 = getPort(comp2,"p2");
    destPort = getPort(comp3,"p3");

    Create an adapter.

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

    Connect the adapter to the three components.

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

    Improve the model layout.

    Simulink.BlockDiagram.arrangeSystem("archModel")

    Input Arguments

    collapse all

    Adapter, specified as a systemcomposer.arch.Adapter object.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: adapter.connectTo(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort])

    Connector on which to insert adapter, specified as a systemcomposer.arch.Connector object.

    This connector cannot be a systemcomposer.arch.PhysicalConnector object.

    If SourcePort or TargetPort are specified, you cannot specify Connector.

    Example: adapter.connectTo(Connector=conn)

    Source ports to connect adapter inputs, specified as an array of data output systemcomposer.arch.ComponentPort objects or an array of data input systemcomposer.arch.ArchitecturePort objects.

    If Connector is specified, you cannot specify SourcePort.

    Example: adapter.connectTo(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort])

    Target ports to connect adapter outputs, specified as an array of data input systemcomposer.arch.ComponentPort objects or an array of data output systemcomposer.arch.ArchitecturePort objects.

    If Connector is specified, you cannot specify TargetPort.

    Example: adapter.connectTo(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort])

    More About

    collapse all

    Version History

    Introduced in R2026a