Main Content

connect

Connect AUTOSAR architecture components and compositions

Since R2020a

Description

connectors = connect(archModel,comp1,comp2) connects the output ports of component or composition comp1 to the input ports of component or composition comp2, based on matching port names. The archModel argument is a model handle returned by a previous call to autosar.arch.createModel or autosar.arch.loadModel. The comp1 and comp2 arguments are component or composition handles returned by previous calls to addComponent, addComposition, or find. The connectors output argument returns one or more connector handles, which are autosar.arch.Connector objects.

example

connectors = connect(archCM,[],comp2) connects the root input ports of parent composition or architecture model archCM to the input ports of child component or composition comp2, based on matching port names.

connectors = connect(archCM,comp1,[]) connects the output ports of child component or composition comp1 to the root output ports of parent composition or architecture model archCM, based on matching port names.

connectors = connect(archModel,port1,port2) connects component, composition, or root architecture port port1 to component, composition or root architecture port port2. The port1 and port2 arguments are port handles returned by previous calls to addPort or find.

Examples

collapse all

This example shows how to connect ports in an AUTOSAR classic architecture model.

Create AUTOSAR classic architecture model.

modelName = 'myArchModel';
archModel = autosar.arch.createModel(modelName);

By default, autosar.arch.createModel creates an AUTOSAR architecture model for the Classic Platform. Mixing classic and adaptive components in the same architecture model is not supported.

At the top level of the model, add a composition, an application component, and a sensor-actuator component.

composition = addComposition(archModel,'Sensors');

addComponent(archModel,'Controller1');
actuator = addComponent(archModel,'Actuator');
set(actuator,'Kind','SensorActuator');

For the architecture model, add two receiver (input) ports and a sender (output) port. The ports appear at the architecture model boundary.

addPort(archModel,'Receiver',{'TPS_Hw','APP_Hw'});
addPort(archModel,'Sender','ThrCmd_Hw');

For the composition block, add two receiver ports and two sender ports. The composition receiver port names match the names of the architecture model receiver ports to which they connect.

addPort(composition,'Receiver',{'TPS_Hw','APP_Hw'});
addPort(composition,'Sender',{'TPS_Perc','APP_Perc'});

For the component blocks, add receiver and sender ports. The component receiver and sender port names match the names of the component, composition, or architecture model ports to which they connect.

controller = find(archModel,'Component','Name','Controller1');
addPort(controller,'Receiver',{'TPS_Perc','APP_Perc'});
addPort(controller,'Sender','ThrCmd_Perc');
addPort(actuator,'Receiver','ThrCmd_Perc');
addPort(actuator,'Sender','ThrCmd_Hw');

At the top level of the model, connect the composition and the components based on matching port names.

connect(archModel,composition,controller);
connect(archModel,controller,actuator);
% Connect specified arch root ports to specified composition and component ports
connect(archModel,archModel.Ports(1),composition.Ports(1));

Connect the architecture root ports to composition and component ports. Rather than relying on matching port names to make connections, use port handles to identify specific architecture, composition, and component ports.

connect(archModel,...
    find(archModel,'Port','Name','APP_Hw'),...
    find(composition,'Port','Name','APP_Hw'));
connect(archModel,actuator.Ports(2),archModel.Ports(3));
% ALTERNATIVELY, connect architecture root ports based on matching port names
% connect(archModel,[],composition);
% connect(archModel,actuator,[]);

layout(archModel);  % Auto-arrange architecture model layout

Inside the Sensors composition, add sensor-actuator components named PedalSnsr and ThrottleSnsr.

names = {'PedalSnsr','ThrottleSnsr'};
sensorSWCs = addComponent(composition,names,'Kind','SensorActuator');

For the component blocks, add receiver and sender ports. The component receiver and sender port names match the names of the composition root ports to which they connect.

pSnsr = find(composition,'Component','Name','PedalSnsr');
tSnsr = find(composition,'Component','Name','ThrottleSnsr');
addPort(pSnsr,'Receiver','APP_Hw');
addPort(pSnsr,'Sender','APP_Perc');
addPort(tSnsr,'Receiver','TPS_Hw');
addPort(tSnsr,'Sender','TPS_Perc');

Connect the Sensors composition root ports to component ports based on matching port names.

connect(composition,[],pSnsr);
connect(composition,pSnsr,[]);
connect(composition,[],tSnsr);
connect(composition,tSnsr,[]);

layout(composition);  % Auto-arrange composition layout

This example shows how to connect ports in an AUTOSAR adaptive architecture model.

Create AUTOSAR adaptive architecture model.

modelName = 'myArchModel';
archModel = autosar.arch.createModel(modelName,'platform','Adaptive');

At the top level of the model, add a composition and an adaptive application component.

composition = addComposition(archModel,'Sensors');
addComponent(archModel,'Filter');

For the architecture model, add two receiver (input) ports and two sender (output) ports. The ports appear at the architecture model boundary.

addPort(archModel,'Receiver',{'Data_Snsr1','Data_Snsr2'});
addPort(archModel,'Sender',{'FilteredData_Snsr1','unFilteredData_Snsr2'});

For the composition block, add two receiver ports and two sender ports. The composition receiver and sender port names match the names of the architecture model receiver and sender ports to which they connect.

addPort(composition,'Receiver',{'Data_Snsr1','Data_Snsr2'});
addPort(composition,'Sender',{'FilteredData_Snsr1','unFilteredData_Snsr2'});

At the top level of the model, connect the architecture root input ports to composition ports, relying on matching port names to make connections.

connect(archModel,[],composition);

Connect the architecture root output ports to composition ports, relying on matching port names to make connections.

connect(archModel,composition,[]);

For the composition block, add a client port.

addPort(composition,'Client','Filter_RPort');

For the component block, add a server port.

filter = find(archModel,'Component','Name','Filter');
addPort(filter,'Server','Filter_PPort');
layout(archModel);

Connect the composition and the component client-server ports. Use port handles to identify specific composition and component ports.

connect(archModel,...
    find(filter,'Port','Name','Filter_PPort'),...
    find(composition,'Port','Name','Filter_RPort'));

Input Arguments

collapse all

AUTOSAR architecture model in which to connect ports. The argument is a model handle returned by a previous call to autosar.arch.createModel or autosar.arch.loadModel.

Example: archModel

AUTOSAR composition or architecture model in which to connect parent and child ports based on matching port names. The argument is a composition or architecture model handle returned by a previous call to addComposition, autosar.arch.createModel, or autosar.arch.loadModel.

Example: archModel

Component or composition for which to connect output ports based on matching port names. The argument is a component or composition handle returned by a previous call to addComponent, addComposition, or find.

Example: composition

Component or composition for which to connect input ports based on matching port names. The argument is a component or composition handle returned by a previous call to addComponent, addComposition, or find.

Example: controller

Component, composition, or root architecture port to connect to another specified port. The argument is a port handle returned by a previous call to addPort or find.

Example: archModel.Ports(1)

Component, composition, or root architecture port to connect to another specified port. The argument is a port handle returned by a previous call to addPort or find.

Example: composition.Ports(1)

Output Arguments

collapse all

Returns one or more AUTOSAR connector handles, which are autosar.arch.Connector objects, with connector properties.

Version History

Introduced in R2020a