If you have Simulink® Coder™ and Embedded Coder® software, you can export composition and component AUTOSAR XML (ARXML) descriptions and generate component code from an AUTOSAR architecture model. Optionally, create a ZIP file to package build artifacts for the model hierarchy, for example, for relocation and integration.
You can export an entire architecture model, a nested composition, or a single component. If you initiate an export that encompasses a composition, the export includes XML descriptions of the composition, component prototypes, and composition ports and connectors.
To prepare for exporting ARXML files, examine and modify XML options. XML options specified at the architecture model level are inherited during export by each component in the model.
To export ARXML files and generate code for an architecture model:
Open an architecture model, such as example model
autosar_tpc_composition. (To open the model in a local
working folder, use
To examine XML options at the architecture model level, select the Modeling tab and select Export > Configure XML Options. The AUTOSAR Dictionary opens in the XML Options view. Modifications you make are inherited by every component in the hierarchy.
For more information, see Configure AUTOSAR XML Options.
To export the architecture model, in the Modeling tab, select Export > Generate Code and ARXML. In the Export Composition dialog box, specify the name of the ZIP file in which to package the generated files. Optionally, specify a path to a folder in which to place the exported ARXML files. To begin the export, click OK.
As the architecture model builds, you can view the build log in the Diagnostic Viewer. First the component models build, each as a standalone top-model build. Finally, composition ARXML is exported. When the build is complete, the current folder contains build folders for the architecture model and each component model in the hierarchy, and the specified ZIP file.
Expand the ZIP file. Its content is organized in
arxml folder. Each AUTOSAR component has
component and implementation description files, while the architecture model has
composition, datatype, interface, and timing description files. The composition
file includes XML descriptions of the composition, component prototypes, and
composition ports and connectors. The datatype, interface, and timing files
aggregate elements from the entire architecture model hierarchy.
src folder. Each component model has a build
folder that contains artifacts from a standalone model build.
To export a nested composition or a single component in an architecture model, use composition or component block cues or right-click options. For example, right-click a component block and select Export Component. Components exported from an architecture model inherit the XML options specified at the architecture model level.
In an architecture model, for export, AUTOSAR schema versions must match between the architecture model and the component models in the hierarchy. If export flags a version difference, fix the discrepancy in the component model or in the architecture model. To view the architecture model schema version, open the Configuration Parameters dialog box. In the Modeling tab, select Model Settings. In the dialog box, navigate to the AUTOSAR code generation options pane.
To export from an architecture model hierarchy programmatically, use the architecture
For example, to generate and package ARXML files and code for example model
% Load AUTOSAR architecture model archModel = autosar.arch.loadModel('autosar_tpc_composition'); % Export ARXML descriptions and code into ZIP file export(archModel,'PackageCodeAndARXML','myArchModel.zip');