Main Content

coder.asap2.VarCriterion

Create variant criterion

Since R2025a

Description

Create a custom variant criterion.

Creation

Description

var_criterion = coder.asap2.VarCriterion creates a variant criterion object. You can use this object to define a custom variant criterion, which can be associated with a variant characteristic.

example

Properties

expand all

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

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

Examples

collapse all

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