How to Amend Label Names

This page explains how to patch label names after model generation to match expected naming conventions.

Label Amendment

Several features of EHANDBOOK-NAVIGATOR are based on the notion that the label names visible in interactive models correspond to label names in an A2L file. Also the function overview in NAV works purely name based. This means, the variable name from an exporting function has to match to the name of the importing function.

There can be cases, however, where the strings that are visible in an ASCET or Simulink model do not directly correspond to an A2L label name or match between functions. In this case, features like label pop-up, INCA visualization or function overview will not work in EHB-NAV.

By means of amending the names of labels in interactive models and the generated screenshots, models and screenshots can be "patched" such that the visible strings do match the expected A2L label names. It works in such a way that during the generation of an interactive model from a source ASCET or Simulink model the strings resembling label names are analyzed and transformed according to a specific set of rules. The rules are specified in a JSON file and passed via an argument to EHB-CB or UGG. The command line parameter is

-labelamendment with "path_to_json_file/name.json" as argument.

The rules for renaming are specified in a JSON file format:

Exact Replacements

Exact replacements are specified as key-value pairs of strings in rule groups marked with the key word "exact". They work straight-forward - the string in the key is replaced by the string in the value:

"Original_Name" : "New_Name"

Here’s an example for a set of exact replacement rules:

{
	"exact": {
		"Epm_rpmEngSpd_Sim" : "Epm_rpmEngSpd_Sim_changed",
		"Two-point-controller" : "Two-point-controller_changed",
		"Lamsoni_Sim" : "Lamsoni_Sim_changed"
	}
}

Pattern-based Replacements

Pattern-based replacement are specified as key value pairs of strings in rule groups marked with the key word "pattern". The keys make use of regular expressions to match strings that shall be amended. The values denote replacement strings. The latter can make use of the match groups defined in the regular expression.

"Target_Pattern" : "Substitude_Pattern"

Here’s an example for a set of pattern based replacement rules:

{
	"pattern": {
		"(.*)_write": "$1",
		"read_(.*)": "$1",
		"read_(.*)_write": "$1",
		"(.*)_middle_(.*)": "$1_$2"
	}
}

If the single character '.' is used for a regular expression it must be escaped by '\\'

"prefix_(.*)\\.postfix" : "$1_postfix",

Here a sample Internet page with further information about regular expressions in general and online testing possibilities: https://freeformatter.com/regex-tester.html

Order in which replacements are applied

The order of rules as well as rule groups is of relevance. Rules within a rule group are applied in sequence. The same applies to rule groups; they are also applied in the sequence specified in the JSON file. Through this, even multiple rules can be applied during a transformation.

A sample file is available in the examples sub folder of the EHB-CB installation directory. (..\examples\configuration\LabelAmendment.json)

On application of label amendment to model hierarchies, clickPic for backward navigation and "open interactive model" does not work!