guardrails Annotation

guardrails is a CML annotation that prevent the constraint engine from changing specified attributes or relations when it resolves the constraint.

Annotationguardrails
Applicable toConstraint
Value Type/ValuesString. A comma-separated list of the attribute or relation names to protect.
DescriptionPrevents the constraint engine from altering the listed attributes or relations to satisfy the constraint. Defines protections at the constraint level instead of on individual attributes and relations, which avoids conflicts with other constraints that share the same elements. When you guard an attribute, the engine can’t change its domain values or When you guard a relation, the engine can’t change its cardinality.

Example 1: Guard an Attribute 

In this generator set model, the UL 2200 compliance constraint requires a secondary voltage of 600V or less. The Voltage attribute is guarded, so the engine can’t change its domain values to satisfy the constraint.

1type GeneratorSet : LineItem {
2    @(configurable = false)
3    int requiredKW = [101..10000];
4    string Voltage = ["220/380", "240/416", "277/480", "7976/13800"];
5    string standardsAndCompliance = ["Certification-CSA", "Listing-UL 2200"];
6
7    int Voltage3 = strtoint(regexpreplace(Voltage, VOLTAGE_REGEX, "$2"), 0);
8
9    // Guard Voltage so the engine resolves the rule by adjusting the
10    // compliance standard, not the domain values of Voltage.
11    @(guardrails = "Voltage")
12    constraint(standardsAndCompliance == "Listing-UL 2200" -> Voltage3 <= 600,
13       "The UL 2200 standard covers stationary engine generator assemblies rated at 600 volts or less.");
14}

Example Description and Configurator Result 

In example 1, the guardrails annotation set to “Voltage”. As a result, if the user selects the “Listing-UL 2200” standard, the engine can’t change the domain values of the Voltage attribute to resolve the conflict. Instead, the engine either satisfies the constraint by changing an unguarded element, such as standardsAndCompliance, or displays a conflict error message. Without the guardrails annotation, the engine restricts the domain values of Voltage to satisfy the constraint.