跳至主要内容

Configure Calculation Tag

Calculation tag is a kind of special tags, the value of which indicates the calculation result of an formula. The parameter of this formula can be a tag or a constant. Also, the expression can utilize some common calculation methods, including arithmetic & logic operation and trigonometric function, etc..

Calculation tag can perform some relatively complex operations, such as converting the acquired sensor value to the real physical quantity (liquid level, wind speed, etc.), so as to make the computation less intensive for the upper computer as well as the device more intelligent.

Each calculation tag corresponds to one expression which may support at most 8 tags as its input variables. For users' convenience, 8 tags are represented by A, B, C, D, E, F, G and H (case insensitive) in the expression.

Add Calculation Tag

Please follow the procedures to add a calculation tag:

  1. Double-click on "Calculation Tag" in the left tree menu.

  2. Click "Add" button to add a new calculation tag.

  3. Fill in the basic information. "Periods (s)" specifies how often the tags are calculated, and its unit is second.

  4. Enter an expression. Uses can select default function or operator from the pull-down lists or type them manually. The example figure shows the calculation expression of "Lighting Failure", the expression logic of which is that the lighting is failed when the value of any tag in four switches is 0.

  5. Double-click the variable box to add a tag.

  6. Click "OK" button to save the changes.

Expression Check

On the right of "Expression" box there is a calculator button. Click it to open "Calc Expression" window shown as below. This interface is roughly the same as "Advanced" setting interface in the above, but with a "=" button and a box displaying the operation result. Besides, the variable boxes here require users to input the variable values rather than tag names.

To verify the expression is correct or not, users can click this buttonto get the result, then review it to see its correctness. After the expression has been verified, click "OK" button to update the value; if users do not want to update it, click "Cancel" button.

Function and Operator Description

Through the drop-down boxes, users can set the functions and operators calculation tag supports, which is divided into five categories: "Mathematical", "Functions", "Trigonometry", "Assignment" and "Boolean logic". Moreover, "Constant" box is also provided, allowing users to select from three constants: pi (the ratio of the circumference to the diameter of a circle), epsilon (the smallest positive double value that is greater than zero) and inf (infinity).

As shown in the figure below, the functions or operators listed in the box can be classified into three types: 1. With no brackets, this indicates binary operations (labeled with 1); 2. With brackets but no comma, this means this function only has one parameter (labeled with 2); 3. With brackets and comma, this means the function supports more than one parameter (labeled with 3).

All functions and operators are described as follows:

(0) Arithmetic & Assignment Operators

OPERATORDEFINITION
+Addition between x and y. (eg: x + y)
-Subtraction between x and y. (eg: x - y)
*Multiplication between x and y. (eg: x * y)
/Division between x and y. (eg: x / y)
%Modulus of x with respect to y. (eg: x % y)
^x to the power of y. (eg: x ^ y)

(1) Equalities & Inequalities

OPERATORDEFINITION
== or =True only if x is strictly equal to y. (eg: x == y)
<> or !=True only if x does not equal y. (eg: x <> y or x != y)
<True only if x is less than y. (eg: x < y)
<=True only if x is less than or equal to y. (eg: x <= y)
>True only if x is greater than y. (eg: x > y)
>=True only if x is greater than or equal to y. (eg: x >= y)

(2) Boolean Operations

OPERATORDEFINITION
trueTrue state or any value other than zero (typically 1).
falseFalse state, value of exactly zero.
andLogical AND, True only if x and y are both true. (eg: x and y)
mandMulti-input logical AND, True only if all inputs are true. Left to right short-circuiting of expressions. (eg: mand(x > y, z < w, u or v, w and x))
morMulti-input logical OR, True if at least one of the inputs are true. Left to right short-circuiting of expressions. (eg: mor(x > y, z < w, u or v, w and x))
nandLogical NAND, True only if either x or y is false. (eg: x nand y)
norLogical NOR, True only if the result of x or y is false. (eg: x nor y)
notLogical NOT, Negate the logical sense of the input. (eg: not(x and y) == x nand y)
orLogical OR, True if either x or y is true. (eg: x or y)
xorLogical XOR, True only if the logical states of x and y differ. (eg: x xor y)
xnorLogical XNOR, True iff the biconditional of x and y is satisfied. (eg: x xnor y)
&Similar to AND but with left to right expression short circuiting optimisation. (eg: (x & y) == (y and x))
``

(3) General Purpose Functions

FUNCTIONDEFINITION
absAbsolute value of x. (eg: abs(x))
avgAverage of all the inputs. (eg: avg(x,y,z,w,u,v) == (x + y + z + w + u + v) / 6)
ceilSmallest integer that is greater than or equal to x.
clampClamp x in range between r0 and r1, where r0 < r1. (eg: clamp(r0,x,r1))
equalEquality test between x and y using normalised epsilon
erfError function of x. (eg: erf(x))
erfcComplimentary error function of x. (eg: erfc(x))
expe to the power of x. (eg: exp(x))
expm1e to the power of x minus 1, where x is very small. (eg: expm1(x))
floorLargest integer that is less than or equal to x. (eg: floor(x))
fracFractional portion of x. (eg: frac(x))
hypotHypotenuse of x and y (eg: hypot(x,y) = sqrt(xx + yy))
iclampInverse-clamp x outside of the range r0 and r1. Where r0 < r1. If x is within the range it will snap to the closest bound. (eg: iclamp(r0,x,r1))
inrangeIn-range returns true when x is within the range r0 and r1. Where r0 < r1. (eg: inrange(r0,x,r1))
logNatural logarithm of x. (eg: log(x))
log10Base 10 logarithm of x. (eg: log10(x))
log1pNatural logarithm of 1 + x, where x is very small. (eg: log1p(x))
log2Base 2 logarithm of x. (eg: log2(x))
lognBase N logarithm of x, where n is a positive integer. (eg: logn(x,8))
maxLargest value of all the inputs. (eg: max(x,y,z,w,u,v))
minSmallest value of all the inputs. (eg: min(x,y,z,w,u))
mulProduct of all the inputs. (eg: mul(x,y,z,w,u,v,t) == (x * y * z * w * u * v * t))
ncdfNormal cumulative distribution function. (eg: ncdf(x))
nequalNot-equal test between x and y using normalised epsilon
powx to the power of y. (eg: pow(x,y) == x ^ y)
rootNth-Root of x, where n is a positive integer. (eg: root(x,3) == x^(1/3))
roundRound x to the nearest integer. (eg: round(x))
roundnRound x to n decimal places where n > 0 and is an integer. (eg: roundn(1.2345678,4) == 1.2346)
sgnSign of x, -1 where x < 0, +1 where x > 0, else zero. (eg: sgn(x))
sqrtSquare root of x, where x >= 0. (eg: sqrt(x))
sumSum of all the inputs. (eg: sum(x,y,z,w,u,v,t) == (x + y + z + w + u + v + t))
truncInteger portion of x. (eg: trunc(x))

(4) Trigonometry Functions

FUNCTIONDEFINITION
acosArc cosine of x expressed in radians. Interval [-1, +1]. (eg: acos(x))
acoshInverse hyperbolic cosine of x expressed in radians. (eg: acosh(x))
asinArc sine of x expressed in radians. Interval [-1, +1]. (eg: asin(x))
asinhInverse hyperbolic sine of x expressed in radians. (eg: asinh(x))
atanArc tangent of x expressed in radians. Interval [-1, +1]. (eg: atan(x))
atan2Arc tangent of (x / y) expressed in radians. [-pi, +pi]. (eg: atan2(x,y))
atanhInverse hyperbolic tangent of x expressed in radians. (eg: atanh(x))
cosCosine of x. (eg: cos(x))
coshHyperbolic cosine of x. (eg: cosh(x))
cotCotangent of x. (eg: cot(x))
cscCosecant of x. (eg: csc(x))
secSecant of x. (eg: sec(x))
sinSine of x. (eg: sin(x))
sincSine cardinal of x. (eg: sinc(x))
sinhHyperbolic sine of x. (eg: sinh(x))
tanTangent of x. (eg: tan(x))
tanhHyperbolic tangent of x. (eg: tanh(x))
deg2radConvert x from degrees to radians. (eg: deg2rad(x))
deg2gradConvert x from degrees to gradians. (eg: deg2grad(x))
rad2degConvert x from radians to degrees. (eg: rad2deg(x))
grad2degConvert x from gradians to degrees. (eg: grad2deg(x))