Operators

In calculation rules for attribute types or calculation functions, the individual operand types (sets of values, values, constants) are linked to one another using operators. When linking attribute types, if all operands have the same data type, the results of attribute calculations are returned as this data type.

For each operator, you can use the mode XML attribute to specify how exceptions are to be handled (e.g. <addtimespan mode="PPM4">). Valid values are PPM3 for the behavior up to and including PPM 3.2.1 and PPM4 for the more fault-tolerant behavior from PPM 4.0 onward.
For reasons of backwards compatibility, the default value is PPM3.
In calculation rules that you create using PPM Customizing Toolkit the operators used are assigned the value PPM4 by default.

The calculation and error behavior of the two different modes is described for each operator starting from chapter Mathematic operators.

In your attribute type calculations, define a default return value defaultvalue, which is assigned to the attribute type to be calculated if the attribute calculation fails.

Warning

Do not combine numerical values with non-numerical values in a calculation rule (e.g., TEXT with DOUBLE), as such calculation rules lead to the calculation being canceled.

Numerical data types can be freely combined with one another (e.g., using the set operator). Values are always given the base unit for the attribute type. For attribute type calculations with mixed numerical data types (e.g., DOUBLE, TIMESPAN, FACTORYTIMESPAN) all values are used without units and the result is saved as the DOUBLE data type. You can then save this value in the relevant base unit as a PPM target attribute of another data type.

An operation is specified in the form of inverted Polish notation, i.e., the operator type is specified first, followed by the operands. In XML notation, it looks like this:

<operator 1>

<operand m>

...

</operand m>

<operand m+1>

...

</operand m+1>

<operator 2>

<operand n>

...

</operand n>

<operand n+1>

...

</operand n+1>

</operator 2>

</operator 1>

The operator XML element returns the calculated numerical value (numerical result of the operands linked by the operator). The unit for the result is determined by the data type of the attribute type to which the result value is assigned. Operators themselves can be part of a higher-level operator.

Example

Calculation of the circumference of a circle with a radius of 6
(Circumference = 2 * p * radius):

<times>

<constant>

<dataitem value="2">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

<constant>

<dataitem value="3.1415">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

<constant>

<dataitem value="6">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

</times>

An alternative option leading to the same result is to create a set from the operands and to multiply all elements in the set by one another:

<product>

<set>

<constant>

<dataitem value="2">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

<constant>

<dataitem value="3.1415">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

<constant>

<dataitem value="6">

<datatype name="DOUBLE"/>

</dataitem>

</constant>

</set>

<product>

The operators described in the following chapters are available for the calculation of attribute type values.