Main Content

createCompositionAsModel

Create Simulink representation of AUTOSAR ARXML software composition

Description

createCompositionAsModel(ar,CompositionName) creates a Simulink® model corresponding to AUTOSAR software composition CompositionName. The composition description is part of AUTOSAR information previously imported from AUTOSAR XML files, which is represented by arxml.importer object ar.The importer creates an initial Simulink representation of the imported AUTOSAR composition. The initial representation provides a starting point for further AUTOSAR configuration and Model-Based Design. For more information, see AUTOSAR ARXML Importer.

example

[mdl, sts] = createCompositionAsModel(ar,CompositionName,Name,Value) specifies additional options for Simulink model creation with one or more Name,Value pair arguments.

example

Examples

collapse all

Import AUTOSAR software composition /Company/Components/ThrottlePositionControlComposition from the file ThrottlePositionControlComposition.arxml. The ARXML file is located at matlabroot/examples/autosarblockset/data, which is on the default MATLAB® path. Create an initial Simulink representation of the composition.

ar = arxml.importer('ThrottlePositionControlComposition.arxml');
names = getComponentNames(ar,'Composition')
names =
  1×1 cell array
    {'/Company/Components/ThrottlePositionControlComposition'}
createCompositionAsModel(ar,'/Company/Components/ThrottlePositionControlComposition');

Import AUTOSAR software composition /pkg/rootComposition from XML file mySWCs.arxml and create an initial Simulink representation of the composition. For components mySwc1 and mySwc2 contained within the composition, use existing Simulink component models rather than creating new ones.

ar = arxml.importer('mySWCs.arxml')
createCompositionAsModel(ar,'/pkg/rootComposition','ComponentModels',{'mySwc1','mySwc2'})

Import AUTOSAR software composition /pkg/rootComposition from XML file mySWCs.arxml and create an initial Simulink representation of the composition. Place Simulink data objects corresponding to AUTOSAR data types into data dictionary ardata.sldd.

ar = arxml.importer('mySWCs.arxml')
createCompositionAsModel(ar,'/pkg/rootComposition','DataDictionary','ardata.sldd')

Import AUTOSAR software composition /Company/Components/ThrottlePositionControlComposition from the file ThrottlePositionControlComposition.arxml. The ARXML file is located at matlabroot/examples/autosarblockset/data, which is on the default MATLAB path. Create an initial Simulink representation of the composition.

For each imported component, the importer stores sharable AUTOSAR properties, such as interfaces and data types, in data dictionary ardata.sldd. Components within the composition can then share the stored properties.

ar = arxml.importer('ThrottlePositionControlComposition.arxml')
createCompositionAsModel(ar,'/Company/Components/ThrottlePositionControlComposition',...
    'ModelPeriodicRunnablesAs','Auto',...
    'DataDictionary','ardata.sldd','ShareAUTOSARProperties',true);

To view the shared properties, open the AUTOSAR dictionary for a component model. This example opens ThrottlePositionSensor. Expand the AUTOSAR dictionary node ardata.sldd. You can view read-only properties, such as shared component interfaces, and modify XML options for composition and component export.

autosar_ui_launch('ThrottlePositionSensor')

Import AUTOSAR software composition /pkg/rootComposition from XML file mySWCs.arxml and create an initial Simulink representation of the composition. Model AUTOSAR periodic runnables as function-call subsystems with periodic rates.

ar = arxml.importer('mySWCs.arxml')
createCompositionAsModel(ar,'/pkg/rootComposition',...
  'ModelPeriodicRunnablesAs','FunctionCallSubsystem')

Import AUTOSAR software composition /pkg/rootComposition from XML file mySWCs.arxml and create an initial Simulink representation of the composition. Use PredefinedVariant Senior to resolve variation points in components at model creation time.

ar = arxml.importer('mySWCs.arxml')
createCompositionAsModel(ar,'/pkg/rootComposition',...
  'PredefinedVariant','/pkg/body/Variants/Senior');

Import AUTOSAR software composition /pkg/rootComposition from XML file mySWCs.arxml and create an initial Simulink representation of the composition. Use SwSystemconstantValueSets A and B to resolve variation points in components at model creation time.

ar = arxml.importer('mySWCs.arxml')
createCompositionAsModel(ar,'/pkg/rootComposition',...
  'SystemConstValueSets',{'/pkg/body/SystemConstantValues/A','/pkg/body/SystemConstantValues/B'});

Input Arguments

collapse all

AUTOSAR information previously imported from XML files, specified as an arxml.importer object handle.

Absolute short-name path of the software composition.

Example: '/Company/Powertrain/Components/RootComposition'

Name-Value Arguments

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: 'ModelPeriodicRunnablesAs','AtomicSubsystem' directs the importer to model AUTOSAR periodic runnables as atomic subsystems with periodic rates.

Names of existing atomic software component models to use when creating a Simulink representation of the composition. The function incorporates the specified existing component models in the composition model instead of creating new ones.

Example: 'ComponentModels',{'mySwc1','mySwc2'}

Simulink data dictionary into which to import data objects corresponding to AUTOSAR data types in the XML file. If the specified dictionary does not already exist, the importer creates it. The model is then associated with that data dictionary.

If you specify true for the 'ShareAUTOSARProperties' argument, the specified data dictionary also stores sharable AUTOSAR properties, such as interfaces and data types, for sharing among components in the composition.

Example: 'DataDictionary','ardata.sldd'

By default, createCompositionAsModel imports AUTOSAR periodic runnables found in ARXML files and attempts to model them as atomic subsystems with periodic rates. If conditions prevent use of atomic subsystems, the function models the periodic runnables as function-call subsystems with periodic rates.

To model periodic runnables only as atomic subsystems, specify 'AtomicSubsystem'. If conditions prevent use of atomic subsystems, the function throws an error.

To model periodic runnables only as function-call subsystems, specify 'FunctionCallSubsystem'.

For more information, see Import AUTOSAR Software Component with Multiple Runnables.

Example: 'ModelPeriodicRunnablesAs','AtomicSubsystem'

Path to a PredefinedVariant defined in the AUTOSAR XML file. A PredefinedVariant describes a combination of system constant values among potentially multiple valid combinations to apply to AUTOSAR software components. Use this argument to resolve variation points in AUTOSAR software components at model creation time. If specified, the importer uses the PredefinedVariant to initialize SwSystemconst data that serves as input to control variation points.

For more information, see Control AUTOSAR Variants with Predefined Value Combinations.

Example: 'PredefinedVariant','/pkg/body/Variants/Senior'

To improve the performance of common tasks in AUTOSAR composition modeling, composition import can store sharable component properties, such as interfaces and data types, into a Simulink data dictionary. Components within the composition can then share the stored properties.

For compositions containing more than 20 software components, sharing AUTOSAR properties among components can significantly improve performance for composition workflows, including import, dictionary navigation, AUTOSAR validation, and code generation. Limiting property replication among components can reduce component model file sizes.

The shared AUTOSAR dictionary provides a central location for viewing and configuring AUTOSAR composition and component properties. You can view read-only properties, such as shared component interfaces, and modify XML options for composition and component export.

To share AUTOSAR properties, specify true. For each imported component, the function stores sharable AUTOSAR properties, such as interfaces and data types, in the Simulink data dictionary specified by the 'DataDictionary' argument. The 'DataDictionary' argument must be specified.

For more information, see Import AUTOSAR Composition and Share AUTOSAR Dictionary.

Example: 'ShareAUTOSARProperties',true

Paths to one or more SystemConstValueSets defined in the AUTOSAR XML file. A SystemConstValueSet specifies a set of system constant values to apply to AUTOSAR software components. Use this argument to resolve variation points in AUTOSAR software components at model creation time. If specified, the importer uses the SystemConstValueSets to initialize SwSystemconst data that serves as input to control variation points.

For more information, see Control AUTOSAR Variants with Predefined Value Combinations.

Example: 'SystemConstValueSets','{'/pkg/body/SystemConstantValues/A','/pkg/body/SystemConstantValues/B'}'

Option to import client-server ports as Simulink function ports, specified as a numeric or logical 1 (true) or 0 (false).

  • true — Port-scoped Simulink functions and function callers are used.

  • false— Global Simulink functions and function callers are used.

Example: "UseFunctionPorts"=true

Data Types: logical

Output Arguments

collapse all

Variable that returns a handle to created model.

Variable that returns true if the import is successful. Otherwise, returns false.

Tips

If you enter the arxml.importer object function call without a terminating semicolon (;), the importer lists the AUTOSAR content of the specified XML file or files. The information includes paths to software components in the AUTOSAR package structure, which you can specify in calls to createCompositionAsModel and createComponentAsModel.

Version History

Introduced in R2017b

expand all