Main Content

Round-Trip Preservation of AUTOSAR XML File Structure and Element Information

To support the round trip of AUTOSAR elements between an AUTOSAR authoring tool (AAT) and Simulink®, ARXML import preserves imported AUTOSAR XML file structure and content for ARXML export. When you import ARXML files for an AUTOSAR component into Simulink®, the importer preserves:

  • AUTOSAR XML file structure. You can compare the ARXML files that you import with the corresponding ARXML files that you export.

  • AUTOSAR element information, including properties, references, and packages. The importer preserves relationships between elements.

After import, you can view and configure AUTOSAR software component elements and properties in the AUTOSAR Dictionary. Use the AUTOSAR Dictionary to configure AUTOSAR elements. The properties that you modify are reflected in exported ARXML descriptions and potentially in generated AUTOSAR-compliant C or C++ code. For more information, see Configure AUTOSAR Elements and Properties or Configure AUTOSAR Adaptive Elements and Properties.

AUTOSAR elements that you create in Simulink® export to one or more modelname*.arxml files, which are separate from the imported XML files. You control the file packaging of new elements by configuring XML options in the AUTOSAR Dictionary. For example, you can set XML option Exported XML file packaging to Single file or Modular. For more information, see Configure AUTOSAR XML Options or Configure AUTOSAR Adaptive XML Options.

When you export ARXML files from a Simulink® model, the code generator preserves the imported XML file structure, element information, and UUIDs, while applying your modifications. The exported files include updated versions of the same ARXML files that you imported, and one or more modelname*.arxml files, based on whether you set Exported XML file packaging to Single file or Modular. The modelname*.arxml files include:

  • Implementation descriptions.

  • If you added AUTOSAR interface or data-related elements in Simulink®, interface and data descriptions.

For the Adaptive Platform, manifests for AUTOSAR executables and service instances are also included.

Suppose that, in a working folder, you create a Simulink® model named Controller.slx from example ARXML file ThrottlePositionController.arxml.

ar = arxml.importer('ThrottlePositionController.arxml');
createComponentAsModel(ar,'/Company/Components/Controller',...
  'ModelPeriodicRunnablesAs','AtomicSubsystem');

In the created model, add an AUTOSAR software address method (SwAddrMethod) named CODE and reference it from an AUTOSAR runnable function.

arProps = autosar.api.getAUTOSARProperties('Controller');
addPackageableElement(arProps,'SwAddrMethod',...
    '/AUTOSAR_Platform/SwAddrMethods','CODE','SectionType','Code')
slMap = autosar.api.getSimulinkMapping('Controller');
mapFunction(slMap,'StepFunction','Runnable_Step','SwAddrMethod','CODE')
The function name value 'StepFunction' is obsolete and will be removed in a
future release. For valid function name values, use
autosar.api.getSimulinkMapping(modelName).find("Functions").
The function name value 'StepFunction' is obsolete and will be removed in a
future release. For valid function name values, use
autosar.api.getSimulinkMapping(modelName).find("Functions").

Display the SwAddrMethod CODE path and step function mapping information.

swAddrMethodPath = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',...
    'SectionType','Code')
swAddrMethodPath = 1x1 cell array
    {'/AUTOSAR_Platform/SwAddrMethods/CODE'}

[arRunnableName,arRunnableSwAddrMethod] = getFunction(slMap,'StepFunction')
The function name value 'StepFunction' is obsolete and will be removed in a
future release. For valid function name values, use
autosar.api.getSimulinkMapping(modelName).find("Functions").
arRunnableName = 
'Runnable_Step'
arRunnableSwAddrMethod = 
'CODE'

You can view the modifications in the AUTOSAR Dictionary, SwAddrMethods view, and the Code Mappings editor, Functions tab.

Build the model, for example, by using the command slbuild('Controller'). If the model has Exported XML file packaging set to Modular, the build exports these ARXML files:

  • ThrottlePositionController.arxml — Updated version of the ARXML file from which the model was created. To track changes, you can compare earlier versions of an ARXML file with the most recent exported version.

  • Controller_implementation.arxml — Component implementation information (always generated).

  • Controller_datatype.arxml — Data-related information that reflects your SwAddrMethod changes to the component model. In the file, AUTOSAR package /AUTOSAR_Platform/SwAddrMethods contains SwAddrMethod CODE.

Related Examples

More About