Main Content

addPort

Add port to AUTOSAR component, composition, or architecture model

Since R2020a

Description

ports = addPort(archCCM,portKind,portNames) adds one or more ports of type portKind to component, composition, or architecture model archCCM.

For classic architectures, valid values for portKind are 'Receiver' and 'Sender'. For adaptive architectures, valid values for portKind are 'Receiver', 'Sender', 'Client', and 'Server'. The portNames argument specifies the names of one or more ports to add.

The archCCM argument is a component, composition, or architecture model handle returned by a previous call to addComponent, addComposition, autosar.arch.createModel, or autosar.arch.loadModel. The ports output argument returns one or more port handles, which are autosar.arch.CompPort or autosar.arch.ArchPort objects.

example

Examples

collapse all

In an AUTOSAR classic architecture model:

  1. Add a composition named Sensors.

  2. At the top level of the model, add an application component named Controller1 and a sensor-actuator component named Actuator.

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

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

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

% Create AUTOSAR classic 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');

layout(archModel);  % Auto-arrange layout

By default, autosar.arch.createModel creates an AUTOSAR architecture model for the Classic Platform. To explicitly specify the Classic Platform, use the platform name-value argument when calling autosar.arch.createModel. Mixing classic and adaptive components in the same architecture model is not supported.

In an AUTOSAR adaptive architecture model:

  1. Add a composition named Sensors.

  2. At the top level of the model, add an adaptive application component named Filter.

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

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

  5. Also on the composition block, add a client port.

  6. For the component block, add a server port. The component server port name matches the name of the component, composition, or architecture model ports to which it connects.

% Create AUTOSAR adaptive architecture model
modelName = 'myArchAdaptive';
archModel = autosar.arch.createModel(modelName,'platform','Adaptive');

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

% Add component at architecture model top level 
addComponent(archModel,'Filter'); % defaults to AdaptiveApplication

% Add architecture ports
addPort(archModel,'Receiver',{'Data_Snsr1','Data_Snsr2'});
addPort(archModel,'Sender',{'FilteredData_Snsr1','FilteredData_Snsr2'});

% Add composition ports
addPort(composition,'Receiver',{'Data_Snsr1','Data_Snsr2'});
addPort(composition,'Sender',{'FilteredData_Snsr1','FilteredData_Snsr2'});
addPort(composition,'Client','Filter_CSPort');

% Add component ports
filter = find(archModel,'Component','Name','Filter');
addPort(filter,'Server','Filter_CSPort');
layout(archModel);  % Auto-arrange layout

Mixing classic and adaptive components in the same architecture model is not supported.

Input Arguments

collapse all

AUTOSAR component, composition, or architecture model to which to add one or more ports. The argument is a component, composition, or architecture model handle returned by a previous call to addComponent, addComposition, autosar.arch.createModel, or autosar.arch.loadModel.

Example: archModel

Type of AUTOSAR ports to add to the specified component, composition, or architecture model. The specified type applies to all added ports.

For classic architectures, valid values for portKind are 'Receiver' and 'Sender'.

For adaptive architectures, valid values for portKind are 'Receiver', 'Sender', 'Client', and 'Server'.

Example: 'Receiver'

Names of the ports to add to the specified component, composition, or architecture model.

Example: {'TPS_Hw','APP_Hw'}

Output Arguments

collapse all

Returns one or more AUTOSAR port handles, which are autosar.arch.CompPort or autosar.arch.ArchPort objects, with port properties.

Version History

Introduced in R2020a

expand all