Main Content

Model AUTOSAR Data Types

这AUTOSAR standard defines platform data types for use by AUTOSAR software components. In Simulink®,,,,you can model AUTOSAR data types used in elements such as data elements, operation arguments, calibration parameters, measurement variables, and inter-runnable variables. If you import an AUTOSAR component from ARXML files, Embedded Coder®导入AutoSar数据类型,并创建所需的相应Simulink数据类型。万博1manbetx在代码生成期间,嵌入式编码器导出了组件模型中使用的数据类型的ARXML描述,并在C代码中生成AutoSar数据类型。

关于汽车数据类型

AutoSar指定适用于:

  • 发件人接口的数据元素

  • Operation arguments of a client-server Interface

  • 校准参数

  • 测量变量

  • 可肺间变量

数据类型分为两类:

  • Platform (primitive) data types, which allow a direct mapping to C intrinsic types.

  • 复合数据类型,将其映射到C数组和结构。

要建模AutoSar平台数据类型,请使用相应的Simulink数据类型。万博1manbetx

汽车平台类型 Simulink Data Type
boolean boolean
float32 单身的
float64 双倍的
sint8 int8
sint16 int16
sint32 int32
sint64 INT64
UINT8 UINT8
uint16 uint16
UINT32 UINT32
Uint64 Uint64

AutoSar复合数据类型是数组和记录,分别由宽信号和总线对象在Simulink中表示。万博1manbetx通过配置宽的信号或总线对象InportorOutportblocks, use the Model Data Editor. On the造型选项卡,单击模型数据编辑器and select theInports/Outportstab. Select the设计看法。从货车和出口列表中,选择要配置的源块。

下图显示了如何指定宽信号,该信号对应于Autosar复合阵列。

这following figure shows how to specify a bus object, which corresponds to an AUTOSAR composite record.

要指定操作原型的数据元素的数据类型和参数,请使用下拉列表Data Type柱子。您可以指定simulink内置数据类万博1manbetx型,例如boolean,,,,单身的, 或者int8, 或者enter an (alias) expression for data type. For example, the following figure shows an aliassint8,对应于Autosar数据类型,在Data Type柱子。

有关指定数据类型的更多指导,您可以使用Data Type Assistanton theSignal Attributes窗格InportorOutportBlock Parameters dialog box or in the Property Inspector.

枚举数据类型

Autosar支万博1manbetx持枚举的数据类型。对于导入过程,如果有相应的simulink枚举数据类型,则软件使用数据类型。万博1manbetx该软件检查两种数据类型是否一致。但是,如果找不到相应的Simulink数据类型,该软件将万博1manbetx使用该软件自动创建枚举数据类型万博1manbetxSimulink.DefineIntenumTypeclass. This automatic creation of data types is useful when you want to import a large quantity of enumerated data types.

Consider the following example:

 basiccolors       0  <上limit> <上limit> 0   红色

该软件使用以下方式创建枚举数据类型

万博1manbetxsimulink.defineIntenumType('BasicColors',... {'red','green','blue'},... [0; 1; 1; 2],...'description',''类型basiccolors的定义。,...'headerFile','rte_type.h',...'addClassNametoenumnames',false);

结构参数

在导出AutoSar软件组件之前,请指定结构参数的数据类型为万博1manbetxsimulink.bus对象。看通过创建参数对象来控制字段数据类型和特征。Otherwise, the software displays the following behavior:

  • 当您验证AutoSar配置时,该软件会发出警告。

  • 构建模型时,软件将每个数据类型定义为anonymous结构and generates a random, nondescriptive name for the data type.

When importing an AUTOSAR software component, if a parameter structure has a data type name that corresponds to an anonymous结构,该软件将数据类型设置为结构。但是,如果组件具有引用此匿名的数据元素结构数据类型,该软件会生成错误。

数据类型

Autosar标准定义了一种使用AutoSAR数据类型的方法,其中将基本数据类型映射到实现数据类型和应用程序数据类型。应用和实现数据类型分开应用程序级的物理属性,例如现实世界的值,数据结构和物理语义范围,即与实现级别属性,例如原始类型的存储最小和最大值(用于原始类型)(用于例如,整数,布尔值或真实)。

该软件支持Simulink万博1manbetx的AutoSar数据类型,往返工作流程:万博1manbetx

  • 对于源自Simulink的AutoSar组件,该软件生成AutoSar应用万博1manbetx程序,实现和基本类型,以保留Simulink数据类型中包含的信息。

    在为Simulink创建的AutoSar软件包结构中,原始组件:万博1manbetx

    • You can specify separate packages to aggregate elements that relate to data types, including application data types, software base types, data type mapping sets, system constants, and units.

    • 实现数据类型在主要数据类型软件包中汇总。

    有关更多信息,请参阅配置AutoSar软件包

  • For round-trip workflows involving AUTOSAR components originated outside MATLAB®,ARXML进口商和出口商保留数据类型信息,并为每种导入的AutoSar数据类型映射。

For information about mapping value constraints between AUTOSAR application data types and Simulink data types, see应用程序数据类型物理约束映射

对于源自Simulink的AutoSar数据类型,您可以控制数据类型导出的万博1manbetx某些方面。例如,您可以控制应用程序数据类型的生成何时,或指定为AutoSar数据类型映射集导出的AutoSar软件包和简短名称。有关更多信息,请参阅配置AutoSar数据类型导出

汽车数据类型万博1manbetxOriginated Workflow

In the Simulink originated (bottom-up) workflow, you create a Simulink model and export the model as an AUTOSAR software component.

该软件生成应用程序和实现数据类型和基本类型,以保留Simulink数据类型中包含的信息:万博1manbetx

  • 对于Si万博1manbetxmulink数据类型,该软件生成实现数据类型。

  • 对于每种定点类型,除了实现数据类型外,该软件还会生成应用程序数据类型compu-method-refelement to preserve scale and bias information. This application data type is mapped to the implementation data type.

笔记

该软件不支持从引用模型生成的代码的应用数据类万博1manbetx型。

Simulink Data Type Autosar XML
Implementation Type 申请类型

原始(不包括固定点),例如myint16

覆盖布尔,整数,真实

myint16= Simulink.AliasType; myInt16.BaseType = 'int16';
 myInt16 VALUE
Not generated

原始(固定点),例如myfixpt

myfixpt = 万博1manbetxsimulink.numerictype;myfixpt.datatypemode =…;myfixpt.isalias = true;
  myfixpt   value 
  myfixpt  

例如,枚举

万博1manbetxsimulink.defineIntenumType('myenum',... {'red','green','blue'},... [1; 2; 2; 3],…);
 myEnum VALUE 
Not generated

例如,记录Myrecord

Myrecord= Simulink.Bus;
  myrecord   struct> struct 
Not generated

汽车数据类型Round-Trip Workflow

In the round-trip workflow, you first use the XML description generated by an AUTOSAR authoring tool to进口Autosar软件组件中的模型。后来,您从模型生成AutoSar C和XML代码。

如果数据原型引用了应用程序数据类型,则该软件将应用程序存储在模型中的实现数据类型映射中,并使用应用程序数据类型名称来定义Simulink数据类型。万博1manbetx

例如,假设创作工具指定应用程序数据类型:

appldt1

在这种情况下,该软件定义了以下Simulink数据类型:万博1manbetx

ImplDT1
Autosar XML Simulink Data Type
申请类型 Implementation Type
  myfixpt  
 myInt
myfixpt = 万博1manbetxsimulink.numerictype;myfixpt.datatypemode =…;myfixpt.isalias = true;

If the data prototype references an implementation data type, the software does not store mapping information and uses the implementation data type name to define the Simulink data type.

这software uses the application data types in simulations and the implementation data types for code generation. When you re-export the AUTOSAR software component, the software uses the stored information to provide the same mapping between the exported application and implementation data types.

应用程序数据类型物理约束映射

在为AutoSar配置的模型中,软件将Simulink数据的最小值和最大值映射到AutoSar应用程序数据类型的相应物理约束值。万博1manbetx

  • 如果导入ARXML文件,则软件导入PhysConstrvalues onApplicationDatatype在arxml文件中最小andMax相应的simulink数据对象和根级I/O信号上的值。万博1manbetx

  • 当您从模型中导出ARXML文件时,该软件导出最小andMaxvalues specified on Simulink data objects and root-level I/O signals to the correspondingApplicationDatatypePhysConstrs in the ARXML files.

  • Simulink data types with unspecified最小andMax对应于AutosarApplicationDatatypeS具有全范围的约束。例如:

    • On import, if thePhysConstrvalues on anApplicationDatatypematch the full lower and upper limits in theInternalConstrfor the associated实现datatype,,,,the importer sets the Simulink最小andMax值为[ ]。在这种情况下,Simulink根万博1manbetx据类型隐式强制执行默认的下限和上限。

    • 在导出时,如果Simulink万博1manbetx最小andMax类型的值是[ ],软件导出该类型的默认下限和上限值(例如,0和1booleanbased type) to the ARXMLPhysConstr描述。

数据类型的Compumethod类别

Autosar软件组件使用计算方法(Compumethods)在Autosar数据的内部值和物理表示之间转换。组合的常见用途是线性数据缩放,校准和测量。

categoryattribute of a CompuMethod represents a specialization of the CompuMethod, which can impose semantic constraints. Thecompumethod代码生成器产生的类别包括:

  • BITFIELD_TEXTTABLE- 将内部值转换为Bitfield文本元素。

  • IDENTICAL- 内部和物理值相同并且不需要转换的浮点或整数功能。

  • 线性- 内部值的线性转换;例如,将内部值乘以一个因子,然后添加一个偏移。

  • RAT_FUNC- 有理函数;类似于线性转换,但具有特定于理性函数的转换限制。

  • scale_linear_and_texttable- 的组合线性and文字台scaling specifications.

  • 文字台- 将内部价值转换为文本元素。

ARXML出口商为每种原始应用程序类型生成Compumethods,从而允许校准和测量工具监视和与应用程序数据进行交互。下表显示了compumethodcategories that the code generator produces for data types in a model that is configured for AUTOSAR.

Data Type compumethodCategory compumethodon Application Type 实施类型的合并
比特菲尔德 BITFIELD_TEXTTABLE 是的 是的
布尔 文字台 是的 是的
枚举没有存储类型 文字台 是的 是的
Enumerated with storage type 文字台 是的 No
固定点 线性
RAT_FUNC(limited to reciprocal scaling)
scale_linear_and_textable
是的 No
Floating-point IDENTICAL
scale_linear_and_textable
是的 No
整数 IDENTICAL
scale_linear_and_textable
是的 No

对于枚举数据类型,ARXML进口商工具遵守AutoSar标准并设置Compumethod类别文字台以下内容:

  1. 如果存在符号属性的值。

  2. 值VT如果是有效的C标识符。

  3. 这value of the shortLabel.

For floating-point and integer data types that do not require conversion between internal and physical values, the exporter generates a generic CompuMethod with categoryIDENTICAL和短名sidentcl

有关配置代码生成的Compumethods的信息,请参见配置Autosar Compumethods

相关示例

更多关于