主要内容

addAdapter

Add adapter to architectural elements

Since R2026a

    Description

    adapter = addAdapter(arch,Name=Value) adds the adapter specified by adapter to the architectural elements specified by arch 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

    Architecture, specified as a systemcomposer.arch.Architecture 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 = rootArch.addAdapter(InputName=["p1","p2"],OutputName=["p3"])

    Name of adapter, specified as a string.

    Example: adapter = rootArch.addAdapter(Name="myAdapter",Connector=conn)

    Data Types: string

    Input port names to create on adapter, specified as a string or array of strings.

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

    Data Types: string

    Output port names to create on adapter, specified as a string or array of strings.

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

    Data Types: string

    Qualified input port element names to map from, specified as a string or array of strings.

    The number of elements in InputElements must match the number of elements in OutputElements.

    Example: adapter = rootArch.addAdapter(InputElements=["p1.elem1","p1.elem2"], OutputElements=["p3.e1","p3.e2"])

    Data Types: string

    Qualified output port element names to map to, specified as a string or array of strings.

    The number of elements in InputElements must match the number of elements in OutputElements.

    Example: adapter = rootArch.addAdapter(InputElements=["p1.elem1","p1.elem2"], OutputElements=["p3.e1","p3.e2"])

    Data Types: string

    Interface conversion mode, specified as one of these options:

    • "None"

    • "Unit Delay"

    • "Rate Transition"

    • "Merge"

    Example: adapter = rootArch.addAdapter(Mode="Rate Transition")

    Data Types: string

    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 = rootArch.addAdapter(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 = rootArch.addAdapter(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 = rootArch.addAdapter(SourcePort=[srcPort1,srcPort2],TargetPort=[destPort])

    Output Arguments

    collapse all

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

    More About

    collapse all

    Version History

    Introduced in R2026a