The AUTOSAR standard defines an approach to AUTOSAR data types in which base data types are mapped to implementation data types and application data types. Application and implementation data types separate application-level physical attributes, such as real-world range of values, data structure, and physical semantics, from implementation-level attributes, such as stored-integer minimum and maximum and specification of a primitive-type (integer, Boolean, real, and so on). For information about modeling data types, see Model AUTOSAR Data Types.
The software supports AUTOSAR data types in Simulink® originated and round-trip workflows:
For AUTOSAR components originated in Simulink, the software generates AUTOSAR application, implementation, and base types to preserve the information contained within Simulink data types.
For round-trip workflows involving AUTOSAR components originated outside MATLAB®, the ARXML importer and exporter preserve data type information and mapping for each imported AUTOSAR data type.
For AUTOSAR data types originated in Simulink, you can control some aspects of data type export. For example, you can control when application data types are generated, or specify the AUTOSAR package and short name exported for AUTOSAR data type mapping sets.
For AUTOSAR data types created in Simulink, by default, the software generates application base types only for
fixed-point data types and enumerated date types with storage types. If you want to
override the default behavior for generating application types, you can configure
the ARXML exporter to generate an application type, along with
the implementation type and base type, for each exported AUTOSAR data type. Use the
XML options parameter ImplementationDataType Reference
(XMLOptions
property
ImplementationDataTypeReference
), for which you can specify
the following values:
Allowed
(default) — Allow direct
reference of implementation types in the generated ARXML
code. If an application data type is not strictly required to describe an
AUTOSAR data type, use an implementation data type reference.
NotAllowed
— Do not allow direct
reference of implementation data types in the generated
ARXML code. Generate an application data type for
each AUTOSAR data type.
To set the ImplementationDataTypeReference
property in the
MATLAB Command Window, use an AUTOSAR property set
function call similar to the following:
hModel = 'autosar_swc_expfcns'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel); arProps=autosar.api.getAUTOSARProperties(hModel); set(arProps,'XmlOptions','ImplementationTypeReference','NotAllowed'); get(arProps,'XmlOptions','ImplementationTypeReference')
To set the ImplementationDataTypeReference
property in the
AUTOSAR Dictionary, select XML Options. Select a value for
parameter ImplementationDataType Reference. Click
Apply.
For AUTOSAR software components created in Simulink, you can control the AUTOSAR package and short name exported for
AUTOSAR data type mapping sets. To configure the data type mapping set package for
export, set the XMLOptions
property
DataTypeMappingPackage
using the AUTOSAR Dictionary or the
AUTOSAR property set
function.
hModel = 'autosar_swc_expfcns'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel); arProps=autosar.api.getAUTOSARProperties(hModel); set(arProps,'XmlOptions','DataTypeMappingPackage','/pkg/dt/DataTypeMappings'); get(arProps,'XmlOptions','DataTypeMappingPackage')
The exported ARXML code uses the specified package. The default
mapping set short-name is the component name ASWC
prefixed to
DataTypeMappingsSet
.
<DATA-TYPE-MAPPING-REFS> <DATA-TYPE-MAPPING-REF DEST="DATA-TYPE-MAPPING-SET"> /pkg/dt/DataTypeMappings/ASWCDataTypeMappingsSet</DATA-TYPE-MAPPING-REF> </DATA-TYPE-MAPPING-REFS> ... <AR-PACKAGE> <SHORT-NAME>DataTypeMappings</SHORT-NAME> <ELEMENTS> <DATA-TYPE-MAPPING-SET UUID="..."> <SHORT-NAME>ASWCDataTypeMappingsSet</SHORT-NAME> ... </DATA-TYPE-MAPPING-SET> </ELEMENTS> </AR-PACKAGE>
You can specify a short name for a data type mapping set using the AUTOSAR
property function addPackageableElement
. The
following example specifies a custom data type mapping set package and name using
MATLAB commands.
% Add a new data type mapping set modelName = 'autosar_swc_expfcns'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(modelName); propObj = autosar.api.getAUTOSARProperties(modelName); newMappingSetPath = '/myPkg/mySubpkg/MyMappingSets'; newMappingSetName = 'MappingSetName'; newMappingSet = [newMappingSetPath '/' newMappingSetName]; addPackageableElement(propObj,'DataTypeMappingSet',newMappingSetPath,newMappingSetName); % Configure the component behavior to use the new data type mapping set swc = get(propObj,'XmlOptions','ComponentQualifiedName'); ib = get(propObj,swc,'Behavior','PathType','FullyQualified'); set(propObj,ib,'DataTypeMapping',newMappingSet); % Force generation of application data types set(propObj,'XmlOptions','ImplementationTypeReference','NotAllowed'); % Build rtwbuild(modelName);
The exported ARXML code uses the specified package and name, as shown below.
<INTERNAL-BEHAVIORS> <SWC-INTERNAL-BEHAVIOR UUID="..."> <SHORT-NAME>IB</SHORT-NAME> <DATA-TYPE-MAPPING-REFS> <DATA-TYPE-MAPPING-REF DEST="DATA-TYPE-MAPPING-SET"> /myPkg/mySubpkg/MyMappingSets/MappingSetName</DATA-TYPE-MAPPING-REF> </DATA-TYPE-MAPPING-REFS> ... </SWC-INTERNAL-BEHAVIOR> </INTERNAL-BEHAVIORS>
To initialize AUTOSAR data objects typed by application data type, the AUTOSAR
standard (R4.1 or later) requires AUTOSAR application value specifications
(ApplicationValueSpecification
s). Embedded Coder® provides the following support:
The ARXML importer uses
ApplicationValueSpecification
s found in imported
ARXML files to initialize the corresponding data
objects in the Simulink model.
Code generation exports ARXML code that uses
ApplicationValueSpecification
s to specify initial
values for AUTOSAR data.
For AUTOSAR parameters typed by implementation data type, code generation exports
ARXML code that uses
NumericalValueSpecification
s and (for enumerated types)
TextValueSpecification
s to specify initial values. If initial
values for parameters specify multiple values, generated code uses
ArrayValueSpecification
s.