Main Content

connect

Create architecture model connections

Description

example

connectors = connect(srcComponent,destComponent) connects the unconnected output ports of srcComponent to the unconnected input ports of destComponent based on matching port names, and returns a handle to the connector.

connectors = connect(architecture,[srcComponent,srcComponent,...],[destComponent,destComponent,...]) connects arrays of components in the architecture.

connectors = connect(architecture,[],destComponent) connects a parent architecture input port to a destination child component.

connectors = connect(architecture,srcComponent,[]) connects a source child component to a parent architecture output port.

example

connectors = connect(srcPort,destPort) connects a source port and a destination port.

connectors = connect(srcPort,destPort,stereotype) connects a source port and a destination port and applies a stereotype to the connector.

example

connectors = connect(___,Name,Value) specifies options using one or more name-value pair arguments in addition to the input arguments in previous syntaxes.

Examples

collapse all

Create and connect two components.

Create a top-level architecture model.

modelName = 'archModel';
arch = systemcomposer.createModel(modelName,true);
rootArch = get(arch,'Architecture');

Create two new components.

names = {'Component1','Component2'};
newComponents = addComponent(rootArch,names);

Add ports to the components.

outPort1 = addPort(newComponents(1).Architecture,'testSig','out'); 
inPort1 = addPort(newComponents(2).Architecture,'testSig','in');

Connect components.

conns = connect(newComponents(1),newComponents(2));

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect two ports.

Create a top-level architecture model.

modelName = 'archModel';
arch = systemcomposer.createModel(modelName,true);
rootArch = get(arch,'Architecture');                  

Create two new components.

names = {'Component1','Component2'};
newComponents = addComponent(rootArch,names);

Add ports to the components.

outPort1 = addPort(newComponents(1).Architecture,'testSig','out'); 
inPort1 = addPort(newComponents(2).Architecture,'testSig','in');

Extract the component ports.

srcPort = getPort(newComponents(1),'testSig');
destPort = getPort(newComponents(2),'testSig');

Connect the ports.

conns = connect(srcPort,destPort);

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect destination architecture port interface element to component.

Create a top-level architecture model.

modelName = 'archModel';
arch = systemcomposer.createModel(modelName,true);
rootArch = get(arch,'Architecture');                  

Create a new component.

newComponent = addComponent(rootArch,'Component1');

Add destination architecture ports to the component and the architecture.

outPortComp = addPort(newComponent.Architecture,'testSig','out');
outPortArch = addPort(rootArch,'testSig','out');

Extract corresponding port objects.

compSrcPort = getPort(newComponent,'testSig');
archDestPort = getPort(rootArch,'testSig');

Add and interface and an interface element, and associate the interface with the architecture port.

interface = arch.InterfaceDictionary.addInterface('interface');
interface.addElement('x');
archDestPort.setInterface(interface);

Select an element on the architecture port and establish a connection.

conns = connect(compSrcPort,archDestPort,'DestinationElement','x');

Improve the model layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Input Arguments

collapse all

Interface and underlying structural definition of model or component, specified as a systemcomposer.arch.Architecture object.

Source component, specified as a systemcomposer.arch.Component object.

Destination component, specified as a systemcomposer.arch.Component object.

Source port to connect, specified as a systemcomposer.arch.ComponentPort or systemcomposer.arch.ArchitecturePort object.

Destination port to connect, specified as a systemcomposer.arch.ComponentPort or systemcomposer.arch.ArchitecturePort object.

Stereotype to apply to the connection, specified as a fully-qualified name in the form '<profile>.<stereotype>'.

Data Types: char

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: connect(archPort,compPort,'SourceElement','a')

Option to apply stereotype to connector, specified as the comma-separated pair consisting of 'Stereotype' and a fully-qualified name in the form '<profile>.<stereotype>'.

This name-value pair only applies when connecting components.

Example: conns = connect(srcComp,destComp,'Stereotype','GeneralProfile.ConnStereotype')

Data Types: char

Option to specify rule for connections, specified as the comma-separated pair consisting of 'Rule' and either 'name' based on the name of ports or 'interface' based on the interface name on ports.

This name-value pair only applies when connecting components.

Example: conns = connect([srcComp1,srcComp2],[destComp1,destComp2],'Rule','interface')

Data Types: char

ption to allow multiple destination components for the same source component, specified as the comma-separated pair consisting of 'MultipleOutputConnectors' and a logical 1 (true) or 0 (false).

This name-value pair only applies when connecting components.

Example: conns = connect(srcComp,[destComp1,destComp2],'MultipleOutputConnectors',true)

Data Types: logical

Option to select source element for connection, specified as the comma-separated pair consisting of 'SourceElement' and a character vector of the name of the signal element.

This name-value pair only applies when connecting ports.

Example: conns = connect(archSrcPort,compDestPort,'SourceElement','x')

Data Types: char

Option to select destination element for connection, specified as the comma-separated pair consisting of 'DestinationElement' and a character vector of the name of the signal element.

This name-value pair only applies when connecting ports.

Example: conns = connect(compSrcPort,archDestPort,'DestinationElement','x')

Data Types: char

Option to specify type of automatic line routing, specified as the comma-separated pair consisting of 'Routing' and one of the following:

  • 'smart' for automatic line routing that takes the best advantage of the blank spaces on the canvas and avoids overlapping other lines and labels.

  • 'on' for automatic line routing.

  • 'off' for no automatic line routing.

Example: conns = connect(srcPort,destPort,'Routing','on')

Data Types: char

Output Arguments

collapse all

Created connections, returned as an array of systemcomposer.arch.Connector objects.

More About

collapse all

Definitions

TermDefinitionApplicationMore Information
architectureA System Composer™ architecture represents a system of components and how they interface with each other structurally and behaviorally. You can represent specific architectures using alternate views.

Different types of architectures describe different aspects of systems:

  • Functional architecture describes the flow of data in a system.

  • Logical architecture describes the intended operation of a system.

  • Physical architecture describes the platform or hardware in a system.

Compose Architecture Visually
modelA System Composer model is the file that contains architectural information, including components, ports, connectors, interfaces, and behaviors.

Perform operations on a model:

  • Extract the root level architecture contained in the model.

  • Apply profiles.

  • Link interface data dictionaries.

  • Generate instances from model architecture.

System Composer models are stored as .slx files.

Create an Architecture Model
componentA component is a nontrivial, nearly-independent, and replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architecture element, such as a function, a system, hardware, software, or other conceptual entity. A component can also be a subsystem or subfunction.Represented as a block, a component is a part of an architecture model that can be separated into reusable artifacts.Components
portA port is a node on a component or architecture that represents a point of interaction with its environment. A port permits the flow of information to and from other components or systems.

There are different types of ports:

  • Component ports are interaction points on the component to other components.

  • Architecture ports are ports on the boundary of the system, whether the boundary is within a component or the overall architecture model.

Ports
connectorConnectors are lines that provide connections between ports. Connectors describe how information flows between components or architectures.A connector allows two components to interact without defining the nature of the interaction. Set an interface on a port to define how the components interact.Connections

Introduced in R2019a