Assignment Examples

This topic provides numerous useful examples of the various ways you can use reference methods in your device template files to perform conversions with constant values and/or reference data group element values. A sample device template file using each example is available upon request; it can be loaded to a DDS and used to test your reference methods. It is called ReferenceTester.dtf.

See the following subsections for details:

For information about example data group element and values used below, see Example Values.

Assign a Conditional Value (A)

Note: The following construct is useful for simple evaluations of two operands. It may be used in conjunction with the constructs described in Assign a Conditional Value (B) and Assign a Conditional Value (C).

In this example, a ref element references the operation opSelect, and a selection element includes four child elements. The selection element defines assignment operations that make up an if-then-else sequence of evaluations. The first three child elements (s0, s1, and s2) define relational expressions. Each child element is evaluated in sequence from lowest number to highest. If a relational expression in a child element is true, the assign value of that element is assigned to that element, processing stops, and the assigned value is returned for the parent data group element. If no relational expression is true, a default value (defVal) is returned for the parent data group element.

In this case, if raw0 = 0, raw1 = 1, and raw2 = 2, "High Alarm" is assigned to the data group element because s2 is the first expression whose condition is met.

<Select desc="Alarm State" readOnly="true" type="string" isRef="1">

<ref prec="0" refOp="opSelect">

<selection>

<s0 assign="Low Alarm" operandLeftId="raw0" op="GT" operandRight="0"/>

<s1 assign="Medium Alarm" operandLeftId="raw1" op="GT" operandRight="2"/>

<s2 assign="High Alarm" operandLeftId="raw2" op="GT" operandRight="1"/>

<defVal assign="No Alarms Found"/>

</selection>

</ref>

</Select>

Useful attributes to know are isRef, prec, refOp, assign, assignId, operandLeft, operandLeftId, operandRight, operandRightId, and op. Useful elements to know are ref, selection, and defVal.

Assign a Conditional Value (B)

Note: The following construct is useful for evaluations of operands that require a bit position or bit mask. It may be used in conjunction with the constructs described in Assign a Conditional Value (A) and Assign a Conditional Value (C).

In this example, a ref element references the operation opSelect, and a selection element includes four child elements. The selection element defines assignment operations that make up an if-then-else sequence of evaluations. The first three child elements (s0, s1, and s2) define relational expressions. Each child element is evaluated in sequence from lowest number to highest. If a relational expression in a child element is true, the assign value of that element is assigned to that element, processing stops, and the assigned value is returned for the parent data group element. If no relational expression is true, a default value (defVal) is returned for the parent data group element.

In this case, if raw0 = 0, raw1 = 1, and raw2 = 2, "MidAlarm" is assigned to the data group element because s1 is the first expression whose condition is met.

<Select desc="Alarm State" readOnly="true" type="string" isRef="1">

<ref prec="0" refOp="opSelect">

<selection>

<s0 assignId="LowAlarm" op="GT">

<operandLeft deid="raw0" bMsk="0x0F"/>

<operandRight value="0"/>

</s0>

<s1 assignId="MidAlarm" op="GT">

<operandLeft deid="raw1" bMsk="0x0F"/>

<operandRight value="0"/>

</s1>

<s2 assignId="HighAlarm" op="GT">

<operandLeft deid="raw2" bMsk="0x0F"/>

<operandRight value="0"/>

</s2>

<defVal assign="No Alarms Found"/>

</selection>

</ref>

</Select>

Useful attributes to know are isRef, prec, refOp, assign, assignId, operandLeft, operandLeftId, operandRight, operandRightId, and op. Useful elements to know are ref, selection, and defVal.

Assign a Conditional Value (C)

Note: The following construct is useful for evaluations where multiple expressions are required to assign a value. It may be used in conjunction with the constructs described in Assign a Conditional Value (A) and Assign a Conditional Value (B).

In this example, a ref element references the operation opSelect, and a selection element includes four child elements. The selection element defines assignment operations that make up an if-then-else sequence of evaluations. The first three child elements (s0, s1, and s2) define relational expressions that are evaluated by an AND/OR operator (andOr). Each child element is evaluated in sequence from lowest number to highest. If a relational expression in a child element is true, the assign value of that element is assigned to that element, processing stops, and the assigned value is returned for the parent data group element. If no relational expression is true, a default value (defVal) is returned for the parent data group element.

In this case, if raw0 = 0 and raw1 = 1, "No Alarms Found" is assigned to the data group element because no expressions have conditions that are met.

<Select desc="Alarm State" readOnly="true" type="string" isRef="1">

<ref prec="0" refOp="opSelect">

<selection>

<s0 assign="Low Alarm" andOr="and">

<expr op="GT">

<operandLeft deid="raw0" bPos="1"/>

<operandRight value="0"/>

</expr>

<expr op="LT">

<operandLeft deid="raw1"/>

<operandRight value="12"/>

</expr>

</s0>

<s1 assign="Medium Alarm" andOr="and">

<expr op="GT">

<operandLeft deid="raw0" bPos="1"/>

<operandRight value="1"/>

</expr>

<expr op="LT">

<operandLeft deid="raw1"/>

<operandRight value="0"/>

</expr>

</s1>

<s2 assign="High Alarm" andOr="and">

<expr op="GT">

<operandLeft deid="raw0" bPos="1"/>

<operandRight value="2"/>

</expr>

<expr op="LT">

<operandLeft deid="raw1"/>

<operandRight value="10"/>

</expr>

</s2>

<defVal assign="No Alarms Found"/>

</selection>

</ref>

</Select>

Useful attributes to know are isRef, prec, refOp, assign, assignId, andOr, expr, op, operandLeft, operandLeftId, operandRight, and operandRightId. Useful elements to know are ref, selection, and defVal.

Assign a Constant

In this example, the child element references the operation opAssign to assign the initial constant 61.

<Assign desc="Assign Constant" readOnly="true" type="ui2" isRef="1">

<ref prec="0" refOp="opAssign" value="61"/>

</Assign>

Useful attributes to know are isRef, prec, refOp, and value. A useful element to know is ref.

Assign a Data Group Element Value

In this example, the child element references the operation opAssignId to assign the current value of the data group element raw61 as the initial value for AssignId.

<AssignId desc="Assign ID" readOnly="true" type="ui2" isRef="1">

<ref prec="0" refOp="opAssignId" deid="raw61"/>

</AssignId>

Useful attributes to know are isRef, prec, refOp, and deid. A useful element to know is ref.

Back to top