coder.asap2.VarCriterion
Description
Create a custom variant criterion.
Creation
Description
creates a variant criterion object. You can use this object to define a custom variant
criterion, which can be associated with a variant characteristic.var_criterion
= coder.asap2.VarCriterion
Properties
Variant criterion name, specified as a character vector or string scalar.
Example:
"CustomVariantCriterion_1"
Description of the variant criterion, specified as a character vector or string scalar.
Example:
"Description of variant criterion"
Enumeration members of the variant criterion, specified as an array of character vectors or a string array. The enumeration members must be unique within the variant criterion.
Example:
["Car" "Body"]
A special measurement object which indicates the variant running on control software, specified as a character vector or string scalar. This is an optional parameter.
Example:
"Measurement_Name"
Specify a special characteristic to change the variant of software running on control unit. This is an optional parameter.
Example:
"Characteristic_Name"
Object Functions
Examples
Export a custom variant characteristic object, export a custom variant criterion object, and generate variant coding section in the A2L file.
A model ECU description object has default variant coding section. Exporting a variant characteristic object is mandatory for the variant coding section to appear in the A2L file. You can modify the properties of variant coding section by using the set
function.
Open and Build Example Model
Open the example model ASAP2Demo
.
open_system("ASAP2Demo");
Build the model.
slbuild("ASAP2Demo");
Create the ECU description object for the model.
descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");
Verify that there are no variant characteristics or variant criterion available in the description object.
find(descObj,"VarCharacteristic") find(descObj,"VarCriterion")
Create and Add Custom Variant Characteristic
To add variant characteristic object to the ASAP2 file, create a custom variant characteristic.
VarCharObj = coder.asap2.VarCharacteristic; VarCharObj.Name = "VehicleSpeedMaxThd"; VarCharObj.CriterionName = ["Fuel","Transmission"]; VarCharObj.VarAddress = ["0x00087050","0x00087040","0x00087068"];
Add the custom variant characteristic to the ECU description object.
add(descObj,VarCharObj);
Add one more custom variant characteristic to the ECU description object.
add(descObj,coder.asap2.VarCharacteristic('BatteryVoltageMin'));
View Variant Characteristic Properties
Get the properties of the newly added variant characteristic by using this command.
get(descObj,'VarCharacteristic','VehicleSpeedMaxThd')
Find and Filter Variant Characteristic
Find the variant characteristic objects present in the ECU description object.
find(descObj,"VarCharacteristic")
Find variant characteristic objects by a property name.
find(descObj,"VarCharacteristic","CriterionName","Fuel")
Update Custom Variant Characteristic Object
Modify the existing variant characteristic VehicleSpeedMaxThd
and view the updated properties.
set(descObj,"VarCharacteristic",'VehicleSpeedMaxThd',... 'CriterionName',["Fuel","Transmission","Country"],... 'VarAddress',["0x012345", "0x01123AD", "0x1AC4BD", "0x1FFFAD"]); get(descObj,'VarCharacteristic','VehicleSpeedMaxThd')
Create and Add Custom Variant Criterion
To add variant criterion object to the ASAP2 file, create a custom variant criterion.
VarCriterionObj = coder.asap2.VarCriterion; VarCriterionObj.Name = 'Fuel'; VarCriterionObj.LongIdentifier = 'Type of Fuel'; VarCriterionObj.Value = ["Electric","Diesel","Petrol"]; VarCriterionObj.VarSelectionCharacteristic = 'VarCharSelect_FuelType';
Add the custom variant criterion to the ECU description object.
add(descObj,VarCriterionObj);
Add one more custom variant criterion to the ECU description object.
add(descObj,coder.asap2.VarCriterion('Transmission'));
View Variant Criterion Properties
Get the properties of the newly added variant criterion by using this command.
get(descObj,'VarCriterion','Fuel')
Find and Filter Variant Criterion
Find the variant criterion objects present in the ECU description object.
find(descObj,'VarCriterion')
Find variant criterion objects by a property name.
find(descObj,"VarCriterion","VarSelectionCharacteristic","VarCharSelect_FuelType")
Update Custom Variant Criterion Object
Modify the existing variant criterion Fuel
and view the updated properties.
set(descObj,"VarCriterion",'Fuel',... 'LongIdentifier','Fuel Possibility in Car',... 'Value',["Electric","Petrol"]); get(descObj,'VarCriterion','Fuel')
Delete Existing Variant Characteristic and Variant Criterion
Remove the newly added variant characteristic and variant criterion from the description object.
delete(descObj,'VarCharacteristic','BatteryVoltageMin'); delete(descObj,'VarCriterion','Transmission');
Update Variant Coding Properties
View the properties of default variant coding section.
get(descObj,'VariantCoding')
Add variant forbidden condition to variant coding object by using the custom data property.
sampleString = ["/begin VAR_FORBIDDEN_COMB",... 'Fuel Electric',... 'Transmission Automatic',... '/end VAR_FORBIDDEN_COMB']; set(descObj,'VariantCoding','CustomData',sampleString);
Export the ASAP2 file and verify that the variant coding section is present.
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions = descObj);
Version History
Introduced in R2025a
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)