Import and Reference Shared AUTOSAR Element Definitions

When developing an AUTOSAR software component in Simulink, you can import AUTOSAR packages containing ARXML element definitions that are common to many components. For example, multiple product lines and teams might share elements such as interfaces and 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 can import shared definitions from ARXML files that are dedicated to describing AUTOSAR elements, not components. 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 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.

    The ARXML file is located at matlabroot/examples/autosarblockset/data, which is on the default MATLAB® search path.

    addpath(fullfile(matlabroot,'/examples/autosarblockset/main'));  % Add path to model
    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.

    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.

  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 measurement and calibration. 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