coder.asap2.getEcuDescriptions
说明
您可以使用 ECU 描述对象及其函数在 ASAP2 文件中添加、删除、查找、过滤、更新和获取 ECU 描述。您可以使用函数为模型创建信息对象。
创建对象
为模型 descObj
= coder.asap2.getEcuDescriptions(modelName
)modelName
创建一个名为 descObj
的 ECU 描述对象。
属性
通过包括或排除注释来生成 A2L 文件。
示例: Comments=true
创建一个用户数据库并自定义 ASAP2 字段,例如:
ASAP2FileName
ByteOrder
HeaderComment
ModParComment
ModCommonComment
示例: CustomizationObject=obj
根据属性对参数和信号进行分组。
示例: CustomizeGroupsBy={'ARRAY','MAP'}
指定一个 32 位整数值,用于指定 ASAP2 文件中的其他地址信息。默认情况下,不需要其他地址信息。
示例: EcuAddressExtension=4
导出的 A2L 文件的名称。
示例: FileName='test_car'
放置导出的 A2L 文件的文件夹的完整路径。
示例: Folder='/home/temp/prjct/'
通过包括或排除 A2ML 和 IF_DATA 部分来生成 A2L 文件。
示例: GenerateXCPInfo=true
根据 A2L 文件的版本,将所有基本数据类型的记录布局导出到名为 RecordLayouts.a2l
的文件中。
示例: IncludeAllRecordLayouts=true
通过包括或排除 AUTOSAR RTE 元素来生成 A2L 文件。
注意
此选项仅适用于 AUTOSAR Classic 模型。
示例: IncludeAutosarRteElements=true
指定 true 以在 A2L 文件中包括默认事件列表。
示例: IncludeDefaultEventList=true
指定 true
可在 ASAP2 文件中包含引用模型元素。指定 flase
可将其排除。
示例: IncludeReferencedModels=true
为 Compu 方法和记录布局生成单独的 A2L 文件。
注意
此选项适用于具有基于 ERT 的系统目标文件的模型。
示例: IncludeSharedElements=true
指定 true
可将变体参数导出到 ASAP2 文件。指定 false
可跳过变体参数。
示例: IncludeVariantCoding=true
通过遵从缩进生成 A2L 文件。
示例: IndentFile=true
包含生成代码符号的模型符号文件的名称。例如,在生成代码中使用的变量的地址。
示例: MapFile='model.elf'
A2L 文件中的自定义模型实例名称。此参量仅适用于 AUTOSAR Adaptive 模型。
示例: ModelClassInstanceName='customObj'
或 ModelClassInstanceName='customNameSpace::customObj'
指定 false
以排除生成的 ASAP2 文件中的 64 位整数。
示例: Support64bitIntegers=false
指定 false
以排除生成的 ASAP2 文件中的结构体元素。
示例: SupportStructureElements=false
将数组布局更新为 ROW_DIR
或 COL_DIR
以按行或按列查看数组数据。
示例: ToggleArrayLayout=true
保存所设置的预设项,并使用更新后的预设项生成 ASAP2 文件,例如包括注释、ASAP2 文件的版本。
示例: UseSavedSettings=false
基于 ASAM 定义的 ASAM MCD-2 MC 标准的 A2L 文件格式。ASAM MCD-2 MC 标准有多个版本。指定所需的 A2L 版本。
示例: Version='1.61'
或 Version='1.31'
对象函数
示例
在 ASAP2 文件中添加、更新、过滤、查找和删除 ECU 描述。
打开并编译示例模型
打开示例模型 ASAP2Demo
open_system("ASAP2Demo");
编译模型。
slbuild("ASAP2Demo");
### Searching for referenced models in model 'ASAP2Demo'. ### Total of 2 models to build. ### Starting serial code generation build. ### Successfully updated the model reference code generation target for: ASAP2DemoModelRef ### Starting build procedure for: ASAP2Demo ### Successful completion of build procedure for: ASAP2Demo Build Summary Model reference code generation targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2DemoModelRef Target (ASAP2DemoModelRef.c) did not exist. Code generated and compiled. 0h 0m 5.8839s Top model targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2Demo Information cache folder or artifacts were missing. Code generated and compiled. 0h 0m 12.037s 2 of 2 models built (0 models already up to date) Build duration: 0h 0m 18.852s
为模型创建 ECU 描述对象。
descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");
获取描述对象中可用计算方法的列表。
find(descObj,"CompuMethod")
ans = 1×10 string
"ASAP2DemoModelRef_CM_double" "ASAP2DemoModelRef_CM_int16_rpm" "ASAP2Demo_CM_double" "ASAP2Demo_CM_double_m_per__s_2_" "ASAP2Demo_CM_double_rpm" "ASAP2Demo_CM_int32" "ASAP2Demo_CM_single" "ASAP2Demo_CM_single_m_per__s_2_" "ASAP2Demo_CM_single_rpm" "ASAP2Demo_CM_uint8"
过滤计算方法,并获取以 rpm 为单位的计算方法列表。
find(descObj,"CompuMethod",Units='rpm')
ans = 1×3 string
"ASAP2DemoModelRef_CM_int16_rpm" "ASAP2Demo_CM_double_rpm" "ASAP2Demo_CM_single_rpm"
创建和添加自定义计算方法
要向 ASAP2 文件添加新计算方法,请创建一个自定义计算方法。
CompuMethod_1 = coder.asap2.CompuMethod; CompuMethod_1.Name = 'CompuMethod_1'; CompuMethod_1.ConversionType = 'LINEAR'; CompuMethod_1.Coefficients = [2 3]; CompuMethod_1.LongIdentifier = 'longIdentifierTest'; CompuMethod_1.Format = '%2.3'; CompuMethod_1.Units = 's';
将该自定义计算方法添加到 ECU 描述对象中。
add(descObj,CompuMethod_1);
获取新添加的计算方法的属性。
get(descObj,"CompuMethod","CompuMethod_1")
ans = CompuMethod with properties: Name: 'CompuMethod_1' LongIdentifier: 'longIdentifierTest' Format: '%2.3' Units: 's' Coefficients: [2 3] ConversionType: 'LINEAR' CompuVTabValues: [1×1 struct] CustomData: ""
要修改计算方法的属性,请使用 set 函数。将计算方法的 ConversionType 字段更新为 TAB_VERB,并定义 CompuVTabValues。
set(descObj,"CompuMethod","CompuMethod_1",ConversionType="TAB_VERB"); set(descObj,"CompuMethod","CompuMethod_1",CompuVTabValues = struct('Literals',["false" "true"],'Values',[0 1]));
获取属性以查看修改后的字段。
modifiedprop = get(descObj,"CompuMethod","CompuMethod_1")
modifiedprop = CompuMethod with properties: Name: 'CompuMethod_1' LongIdentifier: 'longIdentifierTest' Format: '%2.3' Units: 's' Coefficients: [2 3] ConversionType: "TAB_VERB" CompuVTabValues: [1×1 struct] CustomData: ""
modifiedprop.CompuVTabValues
ans = struct with fields:
Literals: ["false" "true"]
Values: [0 1]
使用更新后的 ECU 描述对象生成 ASAP2 文件,并确认 ASAP2 文件包含计算方法 CompuMethod_1。
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
删除计算方法
从描述对象中删除新添加的计算方法。
delete(descObj,"CompuMethod","CompuMethod_1");
创建和添加自定义特征
要向 ASAP2 文件添加新特征,请创建一个自定义特征。
Parameter_1 = coder.asap2.Characteristic; Parameter_1.Name = 'Custom_parameter1'; Parameter_1.LongIdentifier = 'longIdentifierParam'; Parameter_1.UpperLimit = 255; Parameter_1.LowerLimit = 0;
将该自定义特征添加到 ECU 描述对象中。
add(descObj,Parameter_1);
获取新添加的特征的属性。
get(descObj,"Characteristic","Custom_parameter1")
ans = Characteristic with properties: Name: 'Custom_parameter1' LongIdentifier: 'longIdentifierParam' Type: 'VALUE' EcuAddress: '0x0000' CompuMethodName: 'NO_COMPU_METHOD' LowerLimit: 0 UpperLimit: 255 EcuAddressComment: "" EcuAddressExtension: [] CalibrationAccess: 'Calibration' DisplayIdentifier: "" Format: "" BitMask: [] AxisInfo: [] RecordLayout: "" Dimensions: [] Export: 1 MaxRefresh: [1×1 struct] SymbolLink: [1×1 struct] CustomData: ""
要修改特征的属性,请使用 set 函数。更新特征的 UpperLimit 字段。
set(descObj,"Characteristic","Custom_parameter1",UpperLimit=128)
使用更新后的 ECU 描述对象生成 ASAP2 文件,并确认 ASAP2 文件包含特征 Custom_parameter1。
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
从描述对象中删除新添加的特征。
delete(descObj,"Characteristic","Custom_parameter1");
创建和添加自定义测量
要向 ASAP2 文件添加新测量,请创建一个自定义测量。
Signal_1 = coder.asap2.Measurement; Signal_1.Name = 'Custom_signal1'; Signal_1.LongIdentifier = 'longIdentifierSignal'; Signal_1.UpperLimit = 255; Signal_1.LowerLimit = 0;
将该自定义测量添加到 ECU 描述对象中。
add(descObj,Signal_1);
获取新添加的测量的属性。
get(descObj,"Measurement","Custom_signal1")
ans = Measurement with properties: Name: 'Custom_signal1' LongIdentifier: 'longIdentifierSignal' DataType: 'UBYTE' EcuAddress: '0x0000' CompuMethodName: "" LowerLimit: 0 UpperLimit: 255 Raster: [1×1 struct] EcuAddressComment: "" EcuAddressExtension: [] CalibrationAccess: 'NoCalibration' DisplayIdentifier: "" Format: "" BitMask: [] Dimensions: [] Export: 1 MaskData: [1×1 struct] MaxRefresh: [1×1 struct] SymbolLink: [1×1 struct] CustomData: ""
要修改测量的属性,请使用 set 函数。更新测量的 CalibrationAccess 字段。
set(descObj,"Measurement","Custom_signal1",CalibrationAccess='Calibration')
使用更新后的 ECU 描述对象生成 ASAP2 文件,并确认 ASAP2 文件包含名为 Custom_signal1 的测量。
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
从描述对象中删除新添加的测量。
delete(descObj,"Measurement","Custom_signal1");
创建和添加查找表参数
添加一个查找表参数。
LUT_Parameter = coder.asap2.Characteristic; LUT_Parameter.Name = "custom_lookup_table"; LUT_Parameter.Type = "MAP";
创建轴信息并将其添加到参数中。
axis_data = coder.asap2.AxisInfo; axis_data(1).Name = 'BP3'; axis_data(2).Name = 'Bp4'; axis_data(1).CompuMethodName = 'ASAP2Demo_CM_double'; axis_data(2).CompuMethodName = 'ASAP2Demo_CM_double'; axis_data(1).MaxAxisPoints = '3'; axis_data(2).MaxAxisPoints = '3'; axis_data(1).AxisType = 'STD_AXIS'; axis_data(2).AxisType = 'STD_AXIS'; LUT_Parameter.AxisInfo = axis_data;
将查找表参数添加到描述对象。
add(descObj,LUT_Parameter)
使用更新后的 ECU 描述对象生成 ASAP2 文件,并确认 ASAP2 文件包含查找表参数 custom_lookup_table。
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
版本历史记录
在 R2022b 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)