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.

example

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

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(___,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 top level architecture model.

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

Create two new components.

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

Add ports to components.

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

Connect components.

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

View model.

systemcomposer.openModel(modelName);

Improve layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect two ports.

Create top level architecture model.

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

Create two new components.

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

Add ports to components.

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

Extract component ports.

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

Connect ports.

conns = connect(srcPort,destPort);

View model.

systemcomposer.openModel(modelName);

Improve layout.

Simulink.BlockDiagram.arrangeSystem(modelName)

Create and connect destination architecture port interface element to component.

Create top level architecture model.

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

Create new component.

newComponent = addComponent(rootArch,'Component1');

Add destination architecture ports to component and 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 interface, interface element, and associate interface with architecture port.

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

Select element on architecture port and establish connection.

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

View model.

systemcomposer.openModel(modelName);

Improve 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.

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 systemcomposer.profile.Stereotype object.

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

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

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.

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.

Data Types: char

Output Arguments

collapse all

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

Introduced in R2019a