coder.asap2.Characteristic
Description
Create a characteristic object to define parameter element and export it to an ASAP2 file.
Creation
creates a
characteristic object. You can use the object to define a characteristic element and export it
to an ASAP2 file.param
= coder.asap2.Characteristic
Properties
Name
— Parameter name
character vector | string scalar
Specify a name for the custom parameter.
Example:
"CustomParameter_1"
LongIdentifier
— Parameter description
character vector | string scalar
Specify comments and description of the parameter.
Example:
"Description of the parameter"
Type
— Type of parameter
VALUE (default) | ASCII | CURVE | MAP | CUBOID | CUBE_4 | CUBE_5 | VAL_BLK
Specify the list of parameters referred in the group which are already present in the description object.
Example:
MAP
EcuAddress
— Address of the parameter
hexadecimal value
Specify the address of the custom parameter.
Example:
0x1234
CompuMethodName
— Compu method name
string scalar | character vector
Specify a name for the conversion method of the custom parameter.
Example:
custom_conversionmethod
LowerLimit
— Minimum value
parameter value
Specify the minimum possible value for the custom parameter.
Example:
0
UpperLimit
— Maximum value
parameter value
Specify the maximum possible value for the custom parameter.
Example:
63365
EcuAddressComment
— Address replacement
string scalar | character vector
Specify symbols for address replacement.
Example:
"/* @ECU_Address@CHARACTERISTIC_1@ */"
EcuAddressExtension
— Address information
integer
Specify additional address information.
Example:
1
CalibrationAccess
— Access type
Calibration
| NoCalibration
| NotAccessible
| ReadOnly
| ReadWrite
Specify the calibration access type for the custom parameter.
Example:
ReadOnly
DisplayIdentifier
— Display name
string scalar | character vector
Specify a display name for the parameter to appear on calibration tool.
Example:
CustomParam_1
Format
— Display format
string scalar | character vector
Specify a display format for the parameter to appear on calibration tool.
Example:
%3.4
BitMask
— Bit handle
hexadecimal value
Specify to handle the single bits.
Example:
0x3a
AxisInfo
— Axis description
coder.asap2.AxisInfo object
Specify the parameters for the axis description.
Example:
Custom_Axis
ExportArrayAsFixAxis
— Export as fix axis or not
false (default) | true
Specify true
to export array as a look up table of type
FIX_AXIS.
Example:
true
Transpose
— Transpose the axis
false (default) | true
Set true
to transpose the axis. It is applicable only for lookup
tables
Example:
true
ComparisonQuantity
— Reference variable
string scalar | character vector
Specify a valid measurement name as a reference in the ASAP2 file. It is applicable only for lookup tables.
Example:
Custom_Measurement
RecordLayout
— Record layout name
character vector | string scalar
Name of the record layout.
Example:
"Record_DATATYPE"
Dimensions
— Dimensions for array
numeric value
Specify the dimensions for an array data type.
Example:
2
ForceShared
— Standard axis as com axis
false (default) | true
Specify true
to describe standard axis as com axis.
Example:
true
Export
— Export parameter
true (default) | false
Specify true
to export the parameter and false to not export the
parameter to ASAP2 file.
Example:
false
SymbolLink
— Symbol name and offset
struct
Specify reference to symbol name within a linker map file.
Example:
struct('SymbolName','p1_SymbolName','Offset',1)
MaxRefresh
— Maximum refresh value
struct
Specify the maximum refresh rate.
Example:
struct('ScalingUnit',ScalingUnits.ONE_MILLI_SEC,'Rate',100)
CustomData
— Additional description
character vector | string scalar
Specify any additional description that needs to be populated in the characteristic.
Example:
"additional information"
Examples
Customize an ASAP2 File
Add, update, filter, find, and remove ECU descriptions in an ASAP2 file.
Open and Build Example Model
Open the example model ASAP2Demo
open_system("ASAP2Demo");
Build the model.
slbuild("ASAP2Demo");
### Searching for referenced models in model 'ASAP2Demo'. ### Found 1 model reference targets 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 Model reference code generation targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2DemoModelRef Target (ASAP2DemoModelRef.c) did not exist. Code generated and compiled. 0h 0m 8.5574s Top model targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2Demo Information cache folder or artifacts were missing. Code generated and compiled. 0h 0m 14.207s 2 of 2 models built (0 models already up to date) Build duration: 0h 0m 24.52s
Create the ECU description object for the model.
descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");
Get the list of available computation methods in the description object.
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"
Filter the computation methods and get a list of computation methods that use rpm as the unit.
find(descObj,"CompuMethod",Units='rpm')
ans = 1x3 string
"ASAP2DemoModelRef_CM_int16_rpm" "ASAP2Demo_CM_double_rpm" "ASAP2Demo_CM_single_rpm"
Create and Add Custom Computation Method
To add a new computation method to the ASAP2 file, create a custom computation method.
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';
Add the custom computation method to the ECU description object.
add(descObj,CompuMethod_1);
Get the properties of the newly added computation method.
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: ""
To modify a property of the computation method, use set function. Update the ConversionType field of the computation method to TAB_VERB and define the CompuVTabValues.
set(descObj,"CompuMethod","CompuMethod_1",ConversionType="TAB_VERB"); set(descObj,"CompuMethod","CompuMethod_1",CompuVTabValues = struct('Literals',["false" "true"],'Values',[0 1]));
Get the properties to see the modified fields.
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: [1x1 struct] CustomData: ""
modifiedprop.CompuVTabValues
ans = struct with fields:
Literals: ["false" "true"]
Values: [0 1]
Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the computation method 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 Computation Method
Remove the newly added computation method from the description object.
delete(descObj,"CompuMethod","CompuMethod_1");
Create and Add Custom Characteristic
To add a new characteristic to the ASAP2 file, create a custom characteristic.
Parameter_1 = coder.asap2.Characteristic; Parameter_1.Name = 'Custom_parameter1'; Parameter_1.LongIdentifier = 'longIdentifierParam'; Parameter_1.UpperLimit = 255; Parameter_1.LowerLimit = 0;
Add the custom characteristic to the ECU description object.
add(descObj,Parameter_1);
Get the properties of the newly added characteristic.
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: ""
To modify a property of the characteristic, use set function. Update the UpperLimit field of the characteristic.
set(descObj,"Characteristic","Custom_parameter1",UpperLimit=128)
Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the characteristic 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"
Remove the newly added characteristic from the description object.
delete(descObj,"Characteristic","Custom_parameter1");
Create and Add Custom Measurement
To add a new measurement to the ASAP2 file, create a custom measurement.
Signal_1 = coder.asap2.Measurement; Signal_1.Name = 'Custom_signal1'; Signal_1.LongIdentifier = 'longIdentifierSignal'; Signal_1.UpperLimit = 255; Signal_1.LowerLimit = 0;
Add the custom measurement to the ECU description object.
add(descObj,Signal_1);
Get the properties of the newly added measurement.
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: ""
To modify a property of the measurement, use set function. Update the CalibrationAccess field of the measurement.
set(descObj,"Measurement","Custom_signal1",CalibrationAccess='Calibration')
Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the measurement with name 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"
Remove the newly added measurement from the description object.
delete(descObj,"Measurement","Custom_signal1");
Create and Add Lookup Table Parameter
Add a lookup table parameter.
LUT_Parameter = coder.asap2.Characteristic; LUT_Parameter.Name = "custom_lookup_table"; LUT_Parameter.Type = "MAP";
Create and add axis information to the parameter.
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 the lookup table parameter to the description object.
add(descObj,LUT_Parameter)
Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the lookup table parameter 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"
Version History
Introduced in R2022b
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)