delete
Remove element from ASAP2 file
Description
Examples
Customize an ASAP2 File
This example shows how to add, update, filter, find, and remove ECU descriptions in an ASAP2 file.
Open and build the example model
Open the example model rtwdemo_asap2
open_system("rtwdemo_asap2");
Build the model.
rtwbuild("rtwdemo_asap2");
### Starting serial model reference code generation build. ### Successfully updated the model reference code generation target for: rtwdemo_asap2_mdlref ### Starting build procedure for: rtwdemo_asap2 ### Successful completion of build procedure for: rtwdemo_asap2 Build Summary Code generation targets built: Model Action Rebuild Reason ============================================================================================ rtwdemo_asap2_mdlref Code generated and compiled. rtwdemo_asap2_mdlref.c does not exist. Top model targets built: Model Action Rebuild Reason =============================================================================================== rtwdemo_asap2 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 16.658s
Create the ECU description object for the model.
descObj=coder.asap2.getEcuDescriptions("rtwdemo_asap2");
Get the list of available compu methods in the description object using the command:
find(descObj,"CompuMethod")
ans = 1x10 string
Columns 1 through 3
"rtwdemo_asap2_CM..." "rtwdemo_asap2_CM..." "rtwdemo_asap2_CM..."
Columns 4 through 6
"rtwdemo_asap2_CM..." "rtwdemo_asap2_CM..." "rtwdemo_asap2_CM..."
Columns 7 through 9
"rtwdemo_asap2_CM..." "rtwdemo_asap2_CM..." "rtwdemo_asap2_md..."
Column 10
"rtwdemo_asap2_md..."
Filter the compu methods and get the list of compu methods with units as "rpm".
find(descObj,"CompuMethod",Units='rpm')
ans = 1x3 string
"rtwdemo_asap2_CM_..." "rtwdemo_asap2_CM_..." "rtwdemo_asap2_mdl..."
Create and Add a Custom Compu Method
To add a new compu method to the ASAP2 file, create a custom compu method using the commands:
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';
Add the custom compu method to the ECU description object using the command:
add(descObj,CompuMethod_CM1);
Get the properties of the newly added compu method using the command:
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]
To modify any property of the compu method, use set function. Update the "LongIdentifier" field of the compu method using the command:
set(descObj,"CompuMethod","CompuMethod_1",LongIdentifier="longIdentifierCM1")
Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the compu method with name "CompuMethod_1".
coder.asap2.export("rtwdemo_asap2",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "rtwdemo_asap2_DW.rtwdemo_asap2_mdlref_InstanceDa"
Delete a Compu Method
Remove the newly added compu method from the description object using the command:
delete(descObj,"CompuMethod","CompuMethod_1");
Create and Add Custom Characteristic
To add a new characteristic to the ASAP2 file, create a custom characteristic using the commands:
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 using the command:
add(descObj,Parameter_1);
Get the properties of the newly added characteristic using the command:
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 SymbolLink: [1x1 struct]
To modify any property of the characteristic, use set function. Update the "UpperLimit" field of the characteristic using the command:
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 with name "Custom_parameter1".
coder.asap2.export("rtwdemo_asap2",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "rtwdemo_asap2_DW.rtwdemo_asap2_mdlref_InstanceDa"
Remove the newly added characteristic from the description object using the command:
delete(descObj,"Characteristic","Custom_parameter1");
Create and Add Custom Measurement
To add a new measurement to the ASAP2 file, create a custom measurement using the commands:
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 using the command:
add(descObj,Signal_1);
Get the properties of the newly added measurement using the command:
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 SymbolLink: [1x1 struct]
To modify any property of the measurement, use set function. Update the "CalibrationAccess" field of the measurement using the command:
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("rtwdemo_asap2",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "rtwdemo_asap2_DW.rtwdemo_asap2_mdlref_InstanceDa"
Remove the newly added measurement from the description object using the command:
delete(descObj,"Measurement","Custom_signal1");
Create and Add a Lookup Table Parameter
To add a lookup table parameter, create a parameter using the commands:
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 = 'rtwdemo_asap2_CM_double'; axis_data(2).CompuMethodName = 'rtwdemo_asap2_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 with name "custom_lookup_table".
coder.asap2.export("rtwdemo_asap2",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "rtwdemo_asap2_DW.rtwdemo_asap2_mdlref_InstanceDa"
Input Arguments
descObj
— ECU description object
getEcuDescriptions
object
Information object created by using the coder.asap2.getEcuDescriptions
function containing the
ASAP2 properties of a given model.
Example: descObj =
coder.asap2.getEcuDescriptions(<modelName>)
category
— Category in ECU descriptions
AxisPoint
| Characteristic
| CompuMethod
| Function
| Measurement
Specify the category of the element to remove it from the ECU description.
Example: Characteristic
name
— Name from the category
char vector
| string scalar
Specify the name available in the specified category to remove it from the ECU description and ASAP2 file.
Example: Compu_Method1
Example: Parameter_p1
Version History
Introduced in R2022b
See Also
add
| get
| set
| find
| coder.asap2.getEcuDescriptions
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)