Expression syntax of internal signals
An expression signal computes its value from other signals with a formula, for example
{T101.Level} * 0.01 * 120. The server evaluates it each time one of its inputs changes. How to create one is described
in Internal signals.
Expressions on screens, which animate objects, use a different syntax; this page applies only to expression signals.
Signal references
| Form | Example | Note |
|---|---|---|
| In braces | {Line1.Pump1.Current} | Always works, also for path parts that start with a digit, such as {1A.Feeder} |
| Bare path | Line1.Pump1.Current | Must start with a letter or _ |
A path consists of parts of letters, digits and _, separated by dots. A name directly followed by ( is a function, not
a signal. An expression cannot refer to its own signal.
Literals
| Kind | Examples |
|---|---|
| Number | 12, 1.5, .5, 1.5e3 |
| Text | 'AUTO', "AUTO" (no escape characters) |
| Logical | true, false (any capitalisation) |
Operators
From lowest to highest precedence:
| Precedence | Operators | Meaning |
|---|---|---|
| 1 | or, || | Logical or |
| 2 | and, && | Logical and |
| 3 | not, ! | Logical not |
| 4 | ==, !=, <, <=, >, >= | Comparison |
| 5 | +, - | Addition, subtraction; + with a text joins the texts |
| 6 | *, /, % | Multiplication, division, remainder |
| 7 | - (in front) | Negative value |
not binds less tightly than a comparison: not {A} == 1 means not ({A} == 1). Use parentheses when in doubt.
Functions
Function names may be written in any capitalisation.
| Function | Arguments | Result |
|---|---|---|
if(c, a, b) | exactly 3 | a if c is true, otherwise b; only the chosen branch is calculated |
min(x, …) | 1 or more | The smallest value |
max(x, …) | 1 or more | The largest value |
abs(x) | 1 | The absolute value |
floor(x) | 1 | Rounded down |
ceil(x) | 1 | Rounded up |
round(x), round(x, n) | 1 or 2 | Rounded to n decimals (0 by default, at most 15) |
Type rules
- In calculations a logical value counts as 1 or 0, and a text is read as a number. A text that is not a number is an error.
- Two texts are compared alphabetically; otherwise values are compared as numbers. If a text cannot be read as a number,
==is false and!=is true. - As a condition, a number is true when it is not 0, and a text is true when it is not empty,
0orfalse. - The result is converted to the data type of the signal. Whole-number types round it; a result outside the range of the type counts as an error.
Missing and bad inputs
- If any input has no value or a bad quality, the expression is not calculated. The signal keeps its last good value
with a Bad quality, or has no value if it never had one. This applies to all inputs, also to those in the branch
of
ifthat is not used. - Division or remainder by zero and a result that is not a finite number also count as an error, with the same effect.
Limits
| Limit | Value |
|---|---|
| Length of the expression | 4096 characters |
| Different input signals | 64 |
| Nested parentheses and functions | 32 levels |
| Depth of the formula | 64 levels, for example 63 operators in one chain |
Errors
The configuration editor checks the expression when you validate or apply the configuration. The message names the
character position and the problem, for example an unknown function sqrt at character 12.