Main Content

addComponent

Add component to AUTOSAR architecture model

Since R2020a

Description

components = addComponent(archCM,compNames) adds one or more components specified in the compNames argument to composition or architecture model archCM.

The archCM argument is a composition or architecture model handle returned by a previous call to addComposition, autosar.arch.createModel, or autosar.arch.loadModel. The components output argument returns one or more component handles, which are autosar.arch.Component objects.

example

components = addComponent(archCM,compNames,'Kind',value) allows you to specify the component type for all added components. Valid classic component types are Application (the default for classic modeling), SensorActuator, ComplexDeviceDriver, EcuAbstraction, and ServiceProxy. The valid adaptive component type is AdaptiveApplication.

Examples

collapse all

In an AUTOSAR classic architecture model:

  1. Add a composition named Sensors and, inside the composition, add AUTOSAR sensor-actuator components named PedalSnsr and ThrottleSnsr.

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

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

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

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

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

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.

Since R2023a

In an AUTOSAR adaptive architecture model:

  1. Add a composition named Sensors and, inside the composition, add two sensor adaptive application components named Sensor1 and Sensor2.

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

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

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

% Add 2 components inside Sensors
names = {'Sensor1','Sensor2'};
sensorSWCs = addComponent(composition,names,'Kind','AdaptiveApplication');
layout(composition); % auto-arrange layout

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

% Or explicitly set the component kind to AdaptiveApplication
set(filterSWC,'Kind','AdaptiveApplication');  
layout(archModel);  % Auto-arrange layout

Mixing classic and adaptive architecture modeling components is not supported.

Input Arguments

collapse all

AUTOSAR composition or architecture model to which to add one or more components. 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

Names of the components to add to the specified composition or architecture model.

Example: {'PedalSnsr','ThrottleSnsr'}

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

Valid classic component types are Application (the default for classic modeling), SensorActuator, ComplexDeviceDriver, EcuAbstraction, and ServiceProxy. The valid adaptive component type is AdaptiveApplication (the default for adaptive modeling).

Example: 'Kind','SensorActuator'

Output Arguments

collapse all

Returns one or more AUTOSAR component handles, which are autosar.arch.Component objects, with component properties.

Version History

Introduced in R2020a

expand all