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 aCompuMethoddefinition also importsUnitPhysicalDimensiondefinitions. Importing anImplementationDataTypealso imports aSwBaseTypedefinition.

If you import AUTOSAR numeric or enumeration data types, you can use thecreateNumericTypecreateEnumerationfunctions 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, andDimension

    • ImplementationDataTypeSwBaseType

    • ApplicationDataType

    • SwSystemConst,SwSystemConstValueSet, andPredefinedVariant

    • SwRecordLayout

    • SwAddrMethod

    • ClientServerInterface,SenderReceiverInterface,ModeSwitchInterface,NvDataInterface,ParameterInterface, andTriggerInterface.

  2. For each component model that shares a set of definitions, use thearxml.importerfunctionupdateAUTOSARPropertiesto add the element definitions to the model. This example shows how to import definitions from the example shared descriptions fileswaddrmethods.arxml进入示例模型autosar_swc.

    The ARXML file is located atMatlabroot/examples/autosarblockset/data, which is on the default MATLAB®搜索路径。

    addpath(fullfile(matlabroot,'/示例/autosarblockset/main'));%添加模型路径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, seeupdateAUTOSARProperties.

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

  3. 您的模型可以以各种方式引用导入元素。例如,您可以选择导入SwAddrMethodvalues for AUTOSAR data to group the data for calibration and measurement. See the exampleImport AUTOSAR Package into Component Model.

  4. 生成模型代码。导出的ARXML代码包含对导入元素的引用。您导入的定义的元素描述文件将其名称,文件结构和内容保留。

See Also

相关话题