RTLE
EVALUATE(EXPRESSION)
EXPRESSION: A string that can be evaluated to a result. This expression can reference other tags' current or previous values and can return any type (string, number, boolean, null, etc.).
Examples:
EVALUATE('5 + 5')
will always return10
.EVALUATE('tag['Tag'] * 100')
will multiply the value of the tag with nameTag
by100
.
How to Use EVALUATE
The Simulator can use the EVALUATE()
tag address to perform simple operations. This acts as a separate tag and helps to create reliable real-time logic expressions (RTLE) to transform raw data without changing PLC programming.
Key Points
Current Value: Use the
value
keyword to reference a tag's current value.Previous Value: Use the
lastvalue
keyword to reference a tag's previous value.
Evaluation Process
TilliT Edge first evaluates data tags not connected to a simulator, ensuring they are up-to-date.
Then, simulator tags are evaluated one by one.
Tags in the simulator cannot reference other simulator tags because of the evaluation order.
Examples
Current Value:
Using Previous Value:
We have a machine tag with ID 67
that represents the machine's state as an integer. The goal is to convert this integer tag into multiple boolean tags compatible with the EQUIPMENT_STATUS_ template*, which expects boolean values instead of integers.
1
Equipment Running
2
Equipment Faulted
3
Equipment Blocked
4
Equipment Stopped
5
Equipment Starved
Structuring and evaluation script
An evaluation script is simply an expression that when true will cause an event to fire. The script support all types of math operators to help define the exact behavior you require.
There are many TilliT keywords that can be used in your script to substitute an Edge Data Tag value. These are shown below.
value: is replaced with the current value that was read by this tag
lastvalue: is replaced with the previous value that was read by this tag
tag['id']: is replaced with the current value that was read by the specified tag id
now: is replaced with the current unix time in milliseconds
dayOfWeek: is replaced with the current day of the week as a number (0-6)
hours: is replaced with the number of hours into the local day it is
minutes: is replaced with the number of minutes into the local day it is
day: is replaced with the number of days into the month
order.fieldName: is replaced with the corresponding fieldName of the current running order. See the bottom of this page for available fields
orderAttr.attrName: is replaced with the corresponding value of attrName of the current running order.
prevOrder.fieldName: is replaced with the corresponding fieldName of the previous running order.
prevOrderAttr.attrName: is replaced with the corresponding value of attrName of the previous running order.
Trigger Setup:
Set up triggers for events, such as when the machine is running (value = 1
).
Conversion Using RTLE: Use RTLE to create new tags that convert the integer machine state into boolean tags. This is done using a ternary operator to evaluate the integer state as a boolean value.
Extra Logic for Equipment Stopped: Add logic to treat both "machine fault" and "machine stopped" states as a "stopped" event.
Assigning Tags: Each boolean tag is linked to a trigger for
value > 0
, which activates the respective event type.
This approach allows the creation of multiple boolean tags from a single integer tag, ensuring compatibility with templates and providing a clear representation of the machine's state.
Last updated