Real-time expressions allow you to instantly manipulate, transform, and filter data inside of visualization apps such as Tiles and Waves.
This allows you to make changes and calculations on your data without having to export your data to another application. Incoming data will be automatically transformed in real-time based on the input expression.
Getting Started
Step-by-step examples
- Filter out unwanted data (example).
Convert the units of a temperature stream from Celsius to Fahrenheit (example).
Compute energy costs from Watts logged (example).
Map values in a data stream to emojis (example).
Create a new data stream through a mathematical combination of two existing data streams (example).
Search for specific values inside a data stream in Waves (example).
Smooth out a noisy line graph (example).
Round the number of decimal places down to something more easily readable (example).
Combine separate latitude and longitude into a single location stream viewable in the map tile (example).
Merge two data streams into a single data stream (example).
Add static units and/or an emoji icon to displayed data (example).
Display "On" if Any Value is "On" (example).
Convert velocity and acceleration from a binary motor encoder signal (example).
Search for an error condition and display an error message (example).
Using Real-Time Expressions in Tiles
Real-time expressions are executed in Tiles by entering a legal expression in the signal key input field in the tile configuration. Pressing <enter> will update the preview tile with the input expression. Closing the tile configuration box will apply the expression in your Tiles dashboard.
Using Real-Time Expressions in Waves
Real-time expressions are executed in Waves by entering a legal expression in the input field toolbar at the top of Waves. Pressing <enter> will create a new signal based on the input expression.
Syntax
Expressions are prefixed with the "=" character.
Signal Identifiers
Input signals are enclosed in [ ].
example: =[temp_f]*2
Number Literal
Numbers can be specified as integers (0 1234), hexadecimal integers (0xF 0x123F), binary integers (0b1 0b1011), decimals (0.21 123.456), and scientific notation (0e6 10e+5 0.1e-8).
String Literal
Strings are enclosed " ".
example: =[message1] == "hello"
Escape Sequence
Special characters can be escaped using \ .
example: =[signal\[0\]]*2
Unicode escape sequences: \u00 \x0000 \{#00000}
Multiple Inputs, Operators, and Methods in one Expression
Any number of input data streams, operators, and functions can be combined into a single expression. Data streams, operators, and functions can be repeated as many times as desired in a single expression.
example (computes dew point °F from temperature °F and relative humidity by converting to Celsius then back to Fahrenheit):
=convert(convert([Temperature (F)],"F","C")-((100-[Relative Humidity])/5),"C","F")
Long Expressions - Multi-Line Editing
Whitespace characters (newlines, tabs, spaces) are ignored in all expressions. Newlines will automatically increase the height of the edit field. More information ...
Constant Assignment
You can assign an expression to a constant (e.g. =1, ="hello"). This is particularly useful when you want to set a default value for an expression to display in a tile in case the evaluated expression returns an empty set (e.g. =([temp_f] < -60) | "No Values Under -60 Found!" ).
Operators
Operator | Description | Example |
---|---|---|
+ | Add two numbers | =[temp_f]+2 |
- | Subtract two numbers | =[temp_f]-3 |
* | Multiply two numbers | =[temp_f]*4 |
/ | Divide two numbers | =[temp_f]/5 |
- | Negative of a number | =-[temp_f] |
^ | Exponential | =[temp_f]^2 |
% | Modulo | =[temp_f]%2 |
& | Concatenate two strings (more info) | =[message1] & [message2] |
| | Union of two signals (more info) | =[signal1] | [signal2] |
== | Equality (Exact Match) Operator (more info) | =[message1] == "hello" |
!= | Inequality Operator (more info) | =[message1] != "error" |
~ | Partial Match Operator (more info) | =[message1] ~ "err" |
!~ | No Partial Match Operator (more info) | =[message1] !~ "err" |
< | Less Than Operator (more info) | =[temp_f] < 90 |
<= | Less Than or Equal Operator (more info) | =[temp_f] <= 70 |
> | Greater Than Operator (more info) | =[temp_f] > 0 |
>= | Greater Than Or Equal Operator (more info) | =[temp_f] >= 1 |
() | Group | =([temp_f]+2)/3 |
. | Member Operator | =math.max([temp_f], 32) |
: | Map Operator (more info) | =([temp_f]>80):"hot" |
$ | Use Selected Signal in Waves (more info) | =$+2 |
Global Methods
Method | Description | Example |
---|---|---|
convert | Numerical Unit Conversion (more info) | =convert([temp_f], "f", "c") |
smooth | Line Graph Curve Smoothing (more info) | =smooth([temp_f]) |
math.round | Numerical Rounding (more info) | =math.round([temp_f], 2) |
math.sum | Cumulative sum (more info) | =math.sum([data_stream]) |
math.mean | Cumulative average (more info) | =math.mean([data_stream]) |
math.variance | Cumulative variance (more info) | =math.variance([data_stream]) |
math.stdDev | Cumulative standard deviation (more info) | =math.stdDev([data_stream]) |
math.min | Take the lesser of two numbers | =math.min([temp_f], 100) |
math.max | Take the greater of two numbers | =math.max([temp_f], 32) |
math.sqrt | Square root of a number | =math.sqrt([data_stream]) |
math.sin | Sine of a number | =math.sin([data_stream]) |
math.cos | Cosine of a number | =math.cos([data_stream]) |
math.tan | Tangent of a number | =math.tan([data_stream]) |
math.PI | π (constant) | =math.PI |
math.delta | Change in value (more info) | =math.delta([data_stream]) |
math.timeDelta | Change in time (more info) | =math.timeDelta([data_stream], "sec") |
math.timeDerivative | Time derivative (more info) | =math.timeDerivative([data_stream], "sec") |
i2c.addr | i2c address decode | =i2c.addr([i2c_scl],[i2c_sda]) |
i2c.data | i2c data decode | =i2c.data([i2c_scl],[i2c_sda]) |
i2c.rw | i2c read/write decode | =i2c.rw([i2c_scl],[i2c_sda]) |
Comments
0 comments
Article is closed for comments.