addComponent

Add component to AUTOSAR architecture model

Description

example

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.

components = addComponent(archCM,compNames,'Kind',value) allows you to specify the component type for all added components. Valid component types are Application (the default), SensorAccuator, ComplexDeviceDriver, EcuAbstraction, and ServiceProxy.

Examples

collapse all

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

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.

Example: 'Kind','SensorActuator'

Output Arguments

collapse all

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

Introduced in R2020a