Main Content

addPort

Add port to AUTOSAR component, parameter component, composition, or architecture model

Description

ports = addPort(archElementOrModel,portKind,portNames) adds one or more ports specified by portNames of type portKind to the component, parameter software component, composition, or architecture model represented by archElementOrModel.

example

Examples

collapse all

Create an AUTOSAR Blockset architecture model and programmatically add an AUTOSAR composition named Sensors to the canvas.

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

modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);
composition = addComposition(archModel,"Sensors");

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

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

For the architecture model, add two receiver (input) ports and one 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");
layout(archModel);

Create an AUTOSAR Blockset architecture model, and programmatically add an AUTOSAR composition named Sensors to the canvas.

By default, autosar.arch.createModel creates an AUTOSAR architecture model for the Classic Platform. Specify the platform as Adaptive to create an AUTOSAR Adaptive Platform architecture model. Using classic components in an AUTOSAR Adaptive Platform architecture model is not supported.

modelName = "myArchAdaptive";
archModel = autosar.arch.createModel(modelName,platform="Adaptive");
composition = addComposition(archModel,"Sensors");

At the top level of the model, add an adaptive application component named Filter. For the Adaptive Platform components, the component type is AdaptiveApplication.

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","FilteredData_Snsr2"});

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.

Also on the composition block, add a client port.

addPort(archModel,"Receiver",{"Data_Snsr1","Data_Snsr2"});
addPort(composition,"Sender",...
    {"FilteredData_Snsr1","FilteredData_Snsr2"});
addPort(composition,"Client","Filter_CSPort");

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.

filter = find(archModel,"Component","Name","Filter");
addPort(filter,"Server","Filter_CSPort");
layout(archModel);

Create an AUTOSAR Blockset architecture model.

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

Add a parameter component, and an AUTOSAR Classic component.

addComponent(archModel,"ParameterComponent",...
    Kind="ParameterComponent");
addComponent(archModel,"Controller1");

Add ports to the architecture and AUTOSAR Classic component.

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

Add parameter sender ports to the AUTOSAR parameter software component. Connections are automatically created between parameter sender and parameter receiver ports with matching port and appear only in generated ARXML files.

parameterComponent = find(archModel,"ParameterComponent");
addPort(parameterComponent,"ParameterSender","Param_SPort");
...
<CONNECTORS>
  <ASSEMBLY-SW-CONNECTOR UUID="bcdfdb40-a9ee-5e0b-2389-caf35247273b">
      <SHORT-NAME>ParameterProvider_ParameterPort_SensorComponent_ParameterPort</SHORT-NAME>
      <PROVIDER-IREF>
          <CONTEXT-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">/Components/AUTOSARArchitecture/ParameterProvider</CONTEXT-COMPONENT-REF>
          <TARGET-P-PORT-REF DEST="P-PORT-PROTOTYPE">/Components/ParameterProvider/ParameterPort</TARGET-P-PORT-REF>
      </PROVIDER-IREF>
      <REQUESTER-IREF>
          <CONTEXT-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">/Components/AUTOSARArchitecture/SensorComponent</CONTEXT-COMPONENT-REF>
          <TARGET-R-PORT-REF DEST="R-PORT-PROTOTYPE">/Components/ASWC/ParameterPort</TARGET-R-PORT-REF>
      </REQUESTER-IREF>
  </ASSEMBLY-SW-CONNECTOR>
...

Input Arguments

collapse all

AUTOSAR component, parameter software component, composition, or architecture model to add one or more ports to.

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 AUTOSAR Classic and Adaptive Platform components the valid port types are:

  • "Receiver"

  • "Sender"

  • "Client"

  • "Server"

For AUTOSAR Classic Platform parameter software components the only valid port type is "ParameterSender".

Example: 'Receiver'

Names of the ports to add to the specified component, composition, or architecture model, specified as a character vector or string scalar for a single name, or a cell array of character vector or string array for multiple names.

Example: ["TPS_Hw","APP_Hw"]

Example: {'TPS_Hw','APP_Hw'}

Output Arguments

collapse all

One or more AUTOSAR ports, returned as an autosar.arch.CompPort, autosar.arch.ArchPort, or autosar.arch.ParameterPort object or an array of port objects and their properties.

Version History

Introduced in R2020a

expand all