Calculations
Allows the execution of JavaScript functions based on the value of points or SQL queries to the database. This functionality must be enabled in your license.
Screenshot
Configuration
This screen allows defining calculations for points whose Type has been set to Calculation
- Select the display to which the calculated point belongs from the dropdown list located in the upper left area of the window
- The list of points will update according to the selected display
- Fill in the following fields
Field Description Function Function to be used in this calculation Period (secs) Period in seconds between calculation executions Data source Source data for performing the calculation - Click “Save”.
Data source format
Enter text in JSON format containing an array of key:value objects with the following format:
[
{"key":"value_1"},
{"key":"value_2"},
{"key":"value_3"}
]
You must specify as many {“key”:“value”} pairs as the parameters accepted by the selected function.
Data source examples
Taking data from other points by pointId
The Ids of the points whose values will be passed to the selected function are specified. Example:
**
[
{"pointId":"2000"},
{"pointId":"2001"},
{"pointId":"2002"}
]
Since three pointIds have been specified, the selected function must accept three arguments: function(a,b,c) { … }
Taking data from other points by pointName
The Names and Sub-names of the points whose values will be passed to the selected function are specified. Example:
[
{"pointName":"TANK 1:LEVEL"},
{"pointName":"TANK 2:LEVEL"},
{"pointName":"TANK 3:LEVEL"},
{"pointName":"TANK 4:LEVEL"}
]
Since four pointNames have been specified, the selected function must accept four arguments: function(a,b,c,d) { … }
Taking data from SQL queries to the database
SQL statements whose results will be passed to the selected function are specified. Example:
[
{"sqlQuery":"SELECT colName FROM table WHERE colId=10"},
{"sqlQuery":"SELECT colName FROM table WHERE colId=11"},
{"sqlQuery":"SELECT colName FROM table WHERE colId=12"}
]
Combinations of the previous examples
The pointId, pointName and sqlQuery types can be combined. Example:
[
{"pointName":"PUMP 1:STATUS"},
{"pointId" :"1002"},
{"pointId" :"1013"},
{"pointId" :"1024"},
{"pointName":"TANK 3:LEVEL"}
]