Main Content

addComponent

Add component to AUTOSAR architecture model

Description

components = addComponent(archModelOrComposition,compNames) adds one or more application components specified in compNames to architecture model or composition archModelOrComposition.

example

components = addComponent(archModelOrComposition,compNames,Name=Value) specified option using one or more name-value arguments in addition to the input arguments in the previous syntax. For examples, to specify a sensor actuator component type, set Kind to SensorActuator.

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");

Add two components to the composition, and programmatically arrange the components on the canvas.

names = {"PedalSnsr","ThrottleSnsr"};
sensorSWCs = addComponent(composition,names,Kind="SensorActuator");
layout(composition); 

Add components to the AUTOSAR Blockset architecture model at the top level of the modeling hierarchy.

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

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

By default, autosar.arch.createModel creates an AUTOSAR architecture model for the Classic Platform. Specify 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");

Programmatically add two sensor AdaptiveApplication components named Sensor1 and Sensor2 to the Sensors composition.

names = {"Sensor1","Sensor2"};
sensorSWCs = addComponent(composition,names,Kind="AdaptiveApplication");
layout(composition);

Add an AdaptiveApplication component to the top level of the AUTOSAR Blockset architecture model. When adding components to an AUTOSAR Adaptive Platform architecture model the default component type is AdaptiveApplicaton. You can still explicitly set the component type as AdaptiveApplication either when adding the component, or after it has been added to the architecture model.

filterSWC = addComponent(archModel,"Filter");
set(filterSWC,Kind="AdaptiveApplication");  
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");

Add ports to the AUTOSAR parameter component. Connections are created implicitly between parameter ports of the same name and initial value, and appear only in generated ARXML files.

parameterComponent = find(archModel,"ParameterComponent");
addPort(parameterComponent,"ParameterSender","Param_SPort");

Input Arguments

collapse all

AUTOSAR architecture model or composition to add one or more components to. Specify this argument as a autosar.arch.Composition object, or autosar.arch.Model object returned by a previous call to either addComposition, autosar.arch.createModel, or autosar.arch.loadModel.

Example: archModel

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

Example: ["PedalSnsr","ThrottleSnsr"]

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: Kind="ServiceProxy" directs the importer to place data objects corresponding to imported AUTOSAR data types in the specified Simulink® data dictionary.

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

For AUTOSAR Classic Platform components the valid component types are:

  • "Application" (AUTOSAR Classic Platform default)

  • "SensorActuator"

  • "ComplexDeviceDriver"

  • "EcuAbstraction"

  • "ServiceProxy"

  • "ParameterComponent

    AUTOSAR compositions can contain only one parameter software component at the top level of the modeling hierarchy.

For AUTOSAR Adaptive Platform components the only valid component type is "AdaptiveApplication".

When the architecture or composition archModelOrComposition uses the Adaptive Platform then components are automatically imported with componentKind "AdaptiveApplication".

Example: "SensorActuator"

Name of the variant subsystem, specified as a character vector or string scalar. The variant choices are added as component blocks contained with the variant subsystem specified by VariantName and can be found by querying the architecture model for its components.

Example: "VariantComponent"

Data Types: char | string

Output Arguments

collapse all

One or more AUTOSAR components and their properties, returned as an autosar.arch.ParameterComponent object, or an array of autosar.arch.Component objects present in the specified architecture model or composition.

Version History

Introduced in R2020a

expand all