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
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 modelname
*.arxmlSingle 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.
One or more
files, based on whether you set Exported XML file packaging tomodelname
*.arxmlSingle file
orModular
. The
files include:modelname
*.arxmlImplementation 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.
Suppose that, in a working folder, you create a Simulink model named Controller.slx
from example ARXML file
.matlabroot
/help/toolbox/autosar/examples/ThrottlePositionController.arxml
% Create Controller model from AUTOSAR component addpath(fullfile(matlabroot,'help','toolbox','autosar','examples')); 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.
% In AUTOSAR model, add SwAddrMethod CODE to SwAddrMethods package arProps = autosar.api.getAUTOSARProperties('Controller'); addPackageableElement(arProps,'SwAddrMethod',... '/AUTOSAR_Platform/SwAddrMethods','CODE','SectionType','Code') % Map step runnable function to SwAddrMethod CODE slMap = autosar.api.getSimulinkMapping('Controller'); mapFunction(slMap,'StepFunction','Runnable_Step','SwAddrMethod','CODE') % Display SwAddrMethod CODE path and step function mapping information swAddrMethodPath = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',... 'SectionType','Code') [arRunnableName,arRunnableSwAddrMethod] = getFunction(slMap,'StepFunction')
swAddrMethodPath = {'/AUTOSAR_Platform/SwAddrMethods/CODE'} 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.