Main Content

addPort

Add port to AUTOSAR component, composition, or architecture model

Description

example

ports = addPort(archCCM,portKind,portNames) adds one or more ports of type portKind to component, composition, or architecture model archCCM. Valid values for portKind are 'Receiver' and 'Sender'. 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.

Examples

collapse all

In an AUTOSAR 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 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

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.

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.

Introduced in R2020a