Main Content

coder.asap2.getEcuDescriptions

模型的 ECU 描述对象

自 R2022b 起

    说明

    您可以使用 ECU 描述对象及其函数在 ASAP2 文件中添加、删除、查找、过滤、更新和获取 ECU 描述。您可以使用函数为模型创建信息对象。

    创建对象

    descObj = coder.asap2.getEcuDescriptions(modelName) 为模型 modelName 创建一个名为 descObj 的 ECU 描述对象。

    属性

    全部展开

    放置导出的 A2L 文件的文件夹的完整路径。

    示例: Folder='/home/temp/prjct/'

    导出的 A2L 文件的名称。

    示例: FileName='test_car'

    包含生成代码符号的模型符号文件的名称。例如,在生成代码中使用的变量的地址。

    示例: MapFile='model.elf'

    基于 ASAM 定义的 ASAM MCD-2 MC 标准的 A2L 文件格式。ASAM MCD-2 MC 标准有多个版本。指定所需的 A2L 版本。

    示例: Version='1.61'Version='1.31'

    通过包括或排除注释来生成 A2L 文件。

    示例: Comments=true

    通过包括或排除 A2ML 和 IF_DATA 部分来生成 A2L 文件。

    示例: GenerateXCPInfo=true

    A2L 文件中的自定义模型实例名称。此参量仅适用于 AUTOSAR Adaptive 模型。

    示例: ModelClassInstanceName='customObj'ModelClassInstanceName='customNameSpace::customObj'

    通过遵从缩进生成 A2L 文件。

    示例: IndentFile=true

    创建一个用户数据库并自定义 ASAP2 字段,例如:

    • ASAP2FileName

    • ByteOrder

    • HeaderComment

    • ModParComment

    • ModCommonComment

    示例: CustomizationObject=obj

    根据属性对参数和信号进行分组。

    示例: CustomizeGroupsBy={'ARRAY','MAP'}

    根据 A2L 文件的版本,将所有基本数据类型的记录布局导出到名为 RecordLayouts.a2l 的文件中。

    示例: IncludeAllRecordLayouts=true

    指定 false 以排除生成的 ASAP2 文件中的结构体元素。

    示例: SupportStructureElements=false

    指定 false 以排除生成的 ASAP2 文件中的 64 位整数。

    示例: Support64bitIntegers=false

    指定一个 32 位整数值,用于指定 ASAP2 文件中的其他地址信息。默认情况下,不需要其他地址信息。

    示例: EcuAddressExtension=4

    通过包括或排除 AUTOSAR RTE 元素来生成 A2L 文件。

    注意

    此选项仅适用于 AUTOSAR Classic 模型。

    示例: IncludeAutosarRteElements=true

    保存所设置的预设项,并使用更新后的预设项生成 ASAP2 文件,例如包括注释、ASAP2 文件的版本。

    示例: UseSavedSettings=false

    指定 true 以在 A2L 文件中包括默认事件列表。

    示例: IncludeDefaultEventList=true

    将数组布局更新为 ROW_DIRCOL_DIR 以按行或按列查看数组数据。

    示例: ToggleArrayLayout=true

    为 Compu 方法和记录布局生成单独的 A2L 文件。

    注意

    此选项适用于具有基于 ERT 的系统目标文件的模型。

    示例: IncludeSharedElements=true

    对象函数

    addAdd element to ASAP2 file
    deleteRemove element from ASAP2 file
    findFilter and get ECU description names
    getReturn ASAP2 properties of data element
    setSet property for data element

    示例

    全部折叠

    在 ASAP2 文件中添加、更新、过滤、查找和删除 ECU 描述。

    打开并编译示例模型

    打开示例模型 ASAP2Demo

    open_system("ASAP2Demo");

    编译模型。

    rtwbuild("ASAP2Demo");
    ### Searching for referenced models in model 'ASAP2Demo'.
    ### Found 1 model references to update.
    ### Starting serial model reference 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
    
    Code generation targets built:
    
    Model              Action                        Rebuild Reason                       
    ======================================================================================
    ASAP2DemoModelRef  Code generated and compiled.  ASAP2DemoModelRef.c does not exist.  
    
    Top model targets built:
    
    Model      Action                        Rebuild Reason                                    
    ===========================================================================================
    ASAP2Demo  Code generated and compiled.  Code generation information file does not exist.  
    
    2 of 2 models built (0 models already up to date)
    Build duration: 0h 0m 23.37s
    

    为模型创建 ECU 描述对象。

    descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");

    获取描述对象中可用计算方法的列表。

    find(descObj,"CompuMethod")
    ans = 1x10 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 = 1x3 string
        "ASAP2DemoModelRef_CM_int16_rpm"    "ASAP2Demo_CM_double_rpm"    "ASAP2Demo_CM_single_rpm"
    
    

    创建和添加自定义计算方法

    要向 ASAP2 文件添加新计算方法,请创建一个自定义计算方法。

    CompuMethod_CM1 = coder.asap2.CompuMethod;
    CompuMethod_CM1.Name = 'CompuMethod_1';
    CompuMethod_CM1.ConversionType = 'LINEAR';
    CompuMethod_CM1.Coefficients = [2 3];
    CompuMethod_CM1.LongIdentifier = 'longIdentifierTest';
    CompuMethod_CM1.Format = '%2.3';
    CompuMethod_CM1.Units = 's';

    将该自定义计算方法添加到 ECU 描述对象中。

    add(descObj,CompuMethod_CM1);

    获取新添加的计算方法的属性。

    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: [1x1 struct]
             CustomData: ""
    
    

    要修改计算方法的属性,请使用 set 函数。更新计算方法的 LongIdentifier 字段。

    set(descObj,"CompuMethod","CompuMethod_1",LongIdentifier="longIdentifierCM1")

    使用更新后的 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: [1x1 struct]
                 SymbolLink: [1x1 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: [1x1 struct]
          EcuAddressComment: ""
        EcuAddressExtension: []
          CalibrationAccess: 'NoCalibration'
          DisplayIdentifier: ""
                     Format: ""
                    BitMask: []
                 Dimensions: []
                     Export: 1
                   MaskData: [1x1 struct]
                 MaxRefresh: [1x1 struct]
                 SymbolLink: [1x1 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 中推出