|
|
|
Online Help: User Formula |
|
|
|
|
In order to solve the complex calculate function for some kind of report,
also provide a user function designer for user define complex function based on
standard VBScript Language.
Syntax:
Function FunctionName ([Parameter List])
... Function Comment
FunctionName = Return Value
End Function
| "Function" : |
Key word for user function |
| "FunctionName" : |
Function must have unique name |
| "(" : |
Starter of Parameter List |
| "[Parameter List]" : |
Optional, the Parameter will pass into function |
| ")" : |
Close of Parameter list |
| "End Function" : |
Key word of "End of Function" |
Example 1:
In the Sample Project user can define a user function as following,
Function Tilt (C0,C1,C2,C3,C4,C5,RawData)
Tilt = C0 + C1 * RawData + C2 * RawData ^ 2 + C3 * RawData ^ 3 + C4 * RawData ^
4 + C5 * RawData ^ 5
End Function
So the Sensor "S1" with function "Tilt Data" and "Tilt Datum" can defined as following
Tilt Data = Tilt([SENSOR.S1.PARAMETER.C0],
[SENSOR.S1.PARAMETER.C1],
[SENSOR.S1.PARAMETER.C2],
[SENSOR.S1.PARAMETER.C3],
[SENSOR.S1.PARAMETER.C4],
[SENSOR.S1.PARAMETER.C5],
[SENSOR.S1.DATA])
Tilt Datum = Tilt([SENSOR.S1.PARAMETER.C0],
[SENSOR.S1.PARAMETER.C1],
[SENSOR.S1.PARAMETER.C2],
[SENSOR.S1.PARAMETER.C3],
[SENSOR.S1.PARAMETER.C4],
[SENSOR.S1.PARAMETER.C5],
[SENSOR.S1.DATUM])
Tilt-Datum = [SENSOR.S1.FUNCTION.TILT DATA] - [SENSOR.S1.FUNCTION.TILT DATUM]
You will get same result with Sample Project.
Example 2:
This example we will introduce the select function for return different result based
on the Sensor's RawData, as following function
Function Check(RawData)
IF RawData = 9999 THEN Check = 0 ELSE Check = RawData * 100
End Function
In this example, if the sensor's rawdata equal to 9999 then function will return
0, otherwise function will return the calculate result (rawdata * 100).
User can define the function for sensor "S1" with function "CheckValue"
[SENSOR.S1.FUNCTION.CHECKVALUE] = Check([SENSOR.S1.DATA])
|
|
|