Main Content

addComposition

Add composition to AUTOSAR architecture model

Since R2020a

Description

compositions = addComposition(archCM,compNames) adds one or more compositions 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 compositions output argument returns one or more composition handles, which are autosar.arch.Composition objects.

example

Examples

collapse all

In an AUTOSAR classic architecture model, add a composition named Sensors. Inside the composition, add AUTOSAR sensor-actuator components named PedalSnsr and ThrottleSnsr.

% Create AUTOSAR 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

By default, autosar.arch.createModel creates an AUTOSAR architecture model for the Classic Platform, and compositions added to a classic architecture model support classic modeling components. Mixing classic and adaptive components in the same architecture model is not supported.

Since R2023a

In an AUTOSAR adaptive architecture model, add a composition named Sensors. Inside the composition, add two AUTOSAR adaptive application components named Sensor1 and Sensor2.

% 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

Compositions added to an adaptive architecture model support adaptive modeling components. Mixing classic and adaptive components in the same architecture model is not supported.

Input Arguments

collapse all

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

Example: {'Sensors','Actuators'}

Output Arguments

collapse all

Returns one or more AUTOSAR composition handles, which are autosar.arch.Composition objects, with composition properties.

Version History

Introduced in R2020a

expand all