Main Content

connect

Connect AUTOSAR architecture components and compositions

Description

example

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.

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

In an AUTOSAR architecture model:

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

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

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

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

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

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

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

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

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

% Create AUTOSAR architecture model
modelName = 'myArchModel';
archModel = autosar.arch.createModel(modelName);

% Add a composition
composition = addComposition(archModel,'Sensors');

% Add components at architecture model top level
addComponent(archModel,'Controller1');
actuator = addComponent(archModel,'Actuator');
set(actuator,'Kind','SensorActuator');

% Add architecture ports
addPort(archModel,'Receiver',{'TPS_Hw','APP_Hw'});
addPort(archModel,'Sender','ThrCmd_Hw');

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

% Add component ports
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 top level, connect composition and 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));
% Use find to construct port specifications
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

% Add 2 components inside Sensors composition
names = {'PedalSnsr','ThrottleSnsr'};
sensorSWCs = addComponent(composition,names,'Kind','SensorActuator');

% Add component ports inside Sensors
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 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

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.

Introduced in R2020a