Rule expressions

Updated at:

Twin rules for digital twin nodes support various operators and functions that allow you to perform a wide range of data processing tasks.

Operators

The operators are listed in descending order of precedence: ( ), [ ], ., **, !~, *, /, %, +, -, <<, >>, >>>, <, <=, >, >=, ==, !=, &, ^, |, &&, and ||.

Mathematical functions

In the following functions, n, n1, and n2 are required numeric input parameters. All functions return a value of the Double type.

Function expressionDescription
abs(n)Returns the absolute value of n.
acos(n)Returns the arccosine of n.
asin(n)Returns the arcsine of n.
atan(n)Returns the arctangent of n.
ceil(n)Returns the nearest integer to n.
cos(n)Returns the cosine of n.
cosh(n)Returns the hyperbolic cosine of n.
cot(n)Returns the cotangent of n.
exp(n)Returns e to the power of n.
cbrt(n)Returns the cube root of n.
expm1(n)Returns the value of exp(n)-1.

When n is small, this function is more accurate than exp(n)-1.

floor(n)Returns the greatest integer that is less than n.
log(n)Returns the natural logarithm (base e) of n.
log1p(n)Returns the value of log(1+n).

When n is small, this function is more accurate than log(1+n).

log2(n)Returns the base-2 logarithm of n.
log10(n)Returns the base-10 logarithm of n.
pow(n1, n2)Returns the value of n1 raised to the power of n2.
rand()Returns a random number in the range [0, 1).
signum(n)Returns the sign of n. The return value is one of the following:
  • -1: Negative input.
  • 0: Zero input.
  • 1: Positive input.
sin(n)Returns the sine of n.
sinh(n)Returns the hyperbolic sine of n.
sqrt(n)Returns the square root of n.
tan(n)Returns the tangent of n.
tanh(n)Returns the hyperbolic tangent of n.

Conditional functions

Function expressionDescription
condition(expression, resultIfTrue, resultIfFalse)expressionEvaluates an expression and returns a value.

expression is a Boolean value or an expression that evaluates to a Boolean value.

  • expression is true, the function returns the value of resultIfTrue.
  • expression is false, the function returns the value of resultIfFalse.

If the value of resultIfTrue or resultIfFalse is none, no operation is performed.

The data type of the return value depends on the data type of resultIfTrue or resultIfFalse.

value(param, defaultValue)If the param value is empty, the function returns defaultValue. Otherwise, the function returns param.

The param parameter is a basic data type and can be empty. The defaultValue parameter is a basic data type and cannot be empty.

The data type of the return value depends on the data type of defaultValue.

String functions

Function expressionDescription
contains(str1, str2)Checks if string str1 contains string str2.

Returns a Boolean value.

endWith(str1, str2)Checks if string str1 ends with string str2.

Returns a Boolean value.

length(str)Returns the length of string str.

Returns a value of the Double type.

startWith(str1, str2)Checks if string str1 starts with string str2.

Returns a Boolean value.

substring(str, start, end)Returns a substring of string str from the start index (inclusive) to the end index (exclusive).
  • str: The string to operate on. Required.
  • start: The start index. Integer. Required.
  • end: The end index. Integer. Optional.
join(param1, param2)Converts param1 and param2 to strings and concatenates them.

The param1 and param2 parameters can be numeric or string types.

Returns a value of the String type.