====Transform Expression Reference====
This guide describes how to write ARDI-compatible //transform expressions//. This make changes to the incoming data to convert it into a more human-readable form.
===SCALE===
''SCALE| | ||''
The scale function converts a number from one scale to another.
The ‘input’ is the incoming information from your data source, the ‘output’ is the resulting number.
For example, most Modbus data sources give you a number between 0 and 65535. You will usually need to scale these back to the numbers they represent.
So to take a Modbus number and bring it back to a range of 0-100, you can use the following transform…
''SCALE|0|65535|0|100''
====BINARY====
''BINARY||''
This converts a binary number (a number that is either 0 or 1) to text.
Normally this is used to convert between a number and human readable text, such as ‘off’ and ‘on’, ‘open’ or ‘closed’ etc.
It can also be used to invert a number.
For example, if you would like a value of 0 to be ‘Off’ and 1 to be ‘On’, you could use the following transform…
''BINARY|Off|On''
===MATCH===
''MATCH[||]''
This is similar to BINARY in that it converts values to text – but in this case it handles a range of different values.
The properties are a list of value-name pairs. If no match is found, the transform returns ‘Unknown’.
For instance, a system can have four modes that are read as a simple 0-3 number. You could convert them to a text description.
''MATCH|0|Offline|1|Starting|2|Running|3|Stopping''
This converts the fairly unreadable ‘0’ to ‘Offline’, ‘1’ to ‘Starting’, ‘2’ to ‘Running and ‘3’ to ‘Stopping’.
Note that you are much better off using the [[Enumeration]] property type in the scenario above.
===EQ===
''EQ|||''
Returns values if your property is equal to a given number.
The parameters are the number to compare against, the value if the condition is true and the value if it is false.
''EQ|0|Zero|Non-Zero''
Note that if one of the values are an asterisk (*), your existing property value will be retained.
For example, if you wanted your property to read ‘Offline’ when it is zero but show the value at other times, you could use…
''EQ|0|Offline|*''