Function Evaluation allows the user to modify the value of a source tag before it is sent to the destination.
Function Evaluation can be selected when adding a tag in a channel message.
Selecting ‘Function evaluation’ will provide an additional field that holds the function:
The variable ‘x’ is the original tag value that is specified by the XPath for XML, access path for OPC, position for CSV, etc. The result/outcome of the function is used as the ‘new’ source value.
The function evaluation supports the following:
● One variable named ‘x’ which represents the original tag value.
● Brackets: e.g. ((36+x)/(45-21))
● All basic mathematical operators like + (add), - (subtract), / (divide), * (multiply)
● Advanced math operations e.g.:
o Math.Pow(x,2)+x
o 100+Math.Abs(x)
o Math.Sqrt(x*100)
o For more examples check this website.
The function can be entered directly into the Function, f(x)= field.
However, to use function templates or to test the function do the following:
1. Click the ellipsis button () next to the Function,
f(x)= field. This will open the following dialog.
All available functions are listed.
2. Select a function template.
The Function formula definition updates to display that formula.
3. Replace all letters except x with numerical values.
4. To test the formula enable Show sample evaluation.
5. Enter a test value in the x= field. This is the value that would be received from the source.
The result that would be sent to the destination is shown in the fx= field.
6. Click OK.
The function is entered in the function field for the tag.