Main Content

Import and Reference Shared AUTOSAR Element Definitions

When developing an AUTOSAR software component in Simulink®, you can import AUTOSAR element definitions that are common to many components. For example, multiple product lines and teams might share elements such as interfaces, data types, and software address methods (SwAddrMethods). Benefits of sharing AUTOSAR element definitions include lower risk of definition conflicts and easier code integration.

After you create an AUTOSAR component model, you import the definitions from AUTOSAR XML (ARXML) files that contain packages of shared AUTOSAR elements. By default, the imported definitions are read-only, which prevents changes, but you can also import them as read/write. You can then reference the imported elements in your component model.

When you import an element definition, its dependencies are also imported. For example, importing a CompuMethod definition also imports Unit and PhysicalDimension definitions. Importing an ImplementationDataType also imports a SwBaseType definition.

If you import AUTOSAR numeric or enumeration data types, you can use the createNumericType and createEnumeration functions to create corresponding Simulink data type objects.

When you build the model, exported ARXML code contains references to the shared elements. Their definitions remain in the element description ARXML files from which you imported them. The element description files are exported with their names, file structure, and content preserved.

To set up and reuse AUTOSAR element definitions:

  1. Create one or more ARXML files containing definitions of AUTOSAR elements for components to share. Elements that are supported for reference use in Simulink include:

    • CompuMethod, Unit, and Dimension

    • ImplementationDataType and SwBaseType

    • ApplicationDataType

    • SwSystemConst, SwSystemConstValueSet, and PredefinedVariant

    • SwRecordLayout

    • SwAddrMethod

    • ClientServerInterface, SenderReceiverInterface, ModeSwitchInterface, NvDataInterface, ParameterInterface, and TriggerInterface.

  2. For each component model that shares a set of definitions, use the arxml.importer function updateAUTOSARProperties to add the element definitions to the model. This example shows how to import definitions from the example shared descriptions file SwAddrMethods.arxml into the example model autosar_swc.

    openExample('autosarblockset/ReuseAUTOSARElementsInComponentModelExample');
    modelName = 'autosar_swc';
    open_system(modelName);
    ar = arxml.importer('SwAddrMethods.arxml');
    updateAUTOSARProperties(ar,modelName);

    Optionally, using property-value pairs, you can specify subsets of elements to import. For more information, see updateAUTOSARProperties.

    The importer generates an HTML report that details the updates applied to the model.

  3. Your model can reference the imported elements in various ways. For example, you can select imported SwAddrMethod values for AUTOSAR data to group the data for calibration and measurement. See the example Import AUTOSAR Package into Component Model.

  4. Generate model code. The exported ARXML code contains references to the imported elements. The element description files from which you imported definitions are exported with their names, file structure, and content preserved.

See Also

Related Topics