The ValueStream operators is what makes ValueStreams and expressions become alive.
The ValueStream expressions support the following type of operators:
-
Arithmetic: + (addition), - (subtraction), * (multiplication), / (division), ^ (exponential power) and % (modulo). Arithmetic operators are used the following way “$.attr_1 + $.attr_2” or with scalars “$.attr_1 + 5”
-
Unary: ~ (not), - (negate, make negative), @ (absolute). The unary operators are use the following way “~$.pump_running” (which means pump is not running) and “-$.conveyor_speed” which means the negative convey or speed.
-
Comparison: = (equal), < (less than), <= (less than or equal to), > (greater than), >= (greater than or equal to), <> (not equal to). Comparison operators return a boolean ValueStream (true or false for each timestamp). Example “$.speed_1 < $.speed_2”.
-
Boolean: & (AND), | (OR), # (XOR). Returns a boolean ValueStream result.
The following basic functions are provided as well:
- Absolute Value: 'abs()'
- Trigonomatric Functions: 'sin()', 'cos()', ...
- Hyperbolic Functions: ...
Expression evaluation and execution
The expressions are executed using the PE(MD)(AS) rule set, meaning that the calculation is done in the following order:
-
P - Parentheses are evaluated first, anything that is inside the parentheses is calculated before anything outside the parentheses.
-
E - Exponents are evaluated next.
-
MD - Multiplication and Division is calculated next.
-
AS - Addition and Subtraction is calculated at the end.
The evaluation order is always left to right. ValueStream calculations are computational expensive, so be careful of the order. “2 + 2 + $.level” is less computational expensive than “2 + $.level + 2” and “$.level + 2 + 2”. The reason is that they are evaluated as “((2 + 2) + $.level)”, “((2 + $.level) + 2)” and “(($.level + 2) + 2)” respectively. ValueStream expressions can be many thousand of times more expensive than scalar expressions.