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:
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
ImplementationDataType
andSwBaseType
ApplicationDataType
SwSystemConst
,SwSystemConstValueSet
, andPredefinedVariant
SwRecordLayout
SwAddrMethod
ClientServerInterface
,SenderReceiverInterface
,ModeSwitchInterface
,NvDataInterface
,ParameterInterface
, andTriggerInterface
.
For each component model that shares a set of definitions, use the
arxml.importer
functionupdateAUTOSARProperties
to add the element definitions to the model. This example shows how to import definitions from the example shared descriptions fileSwAddrMethods.arxml
into the example modelautosar_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.
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.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.