|
Register the formula.
syntax
AddExpression(
name,
expression
[,ontimer = -1]
[,offtimer = -1]
)
Parameters
name
|
|
Type:
|
character
|
|
The expression name. Multiple expression names can be specified as an array.
|
expression
|
|
Type:
|
character
|
|
An expression. Multiple expressions can be specified as an array. Expressions are written in bind format.
Example: "U01.F01.T01"
Example: "U01.F01.T01+ U01.F01.T02"
Example: "U01.F01.T01 > 100"
|
ontimer
|
|
Type:
|
character
|
|
Wait time (ms) until the device is identified as On. Can be specified as an array.
-1 means no wait time is specified.
After changing from Off to On, if the time specified by ontimer has passed, OnExpressionValueChanged will occur. If it returns to Off before the time has passed, OnExpressionValueChanged will not occur (if -1 is specified for offtimer, OnExpressionValueChanged will occur if the time specified by ontimer has passed after the value changed).
|
offtimer
|
|
Type:
|
Number
|
|
Wait time (ms) until identifying Off. Can be specified as an array.
-1 means no wait time is specified.
After changing from On to Off, if the time specified by offtimer has passed, OnExpressionValueChanged will occur. If it returns to On before the time has passed, OnExpressionValueChanged will not occur.
|
Return Value
|
|
Type:
|
Boolean
|
|
FALSE - Failure. TRUE - Success.
|
Explanation
Register the expression. After registration, the OnExpressionValueChanged event will be called when the value of the expression changes. The event will occur within the object registered with AddExpression.
|
Example
When calling GetVal in the script of the object that registered the tag
|
event OnInitialize()
{
AddExpression("EX01", "U01.F01.T01 + U01.F01.T02");
}
event OnExpressionValueChanged (name,value,firstevent)
{
SvsDump(value);
}
|
If you want to handle multiple expressions together, you can also specify the expression names and expressions as an array.
If any one of the AddExpression fails, the return value will be FALSE. Even if an expression fails to be added, AddExpression will be executed until the last expression.
When handling multiple tags together
|
var vNames = c("EX01"," EX02"," EX03");
var vExpressions = c("U01.F01.T01 + U01.F01.T02", "U01.F01.T01 == T", "U01.F01.T01 > 100");
event OnInitialize()
{
AddExpression(vNames, vExpressions);
}
event OnExpressionValueChanged(name,value,firstevent)
{
if (name == vNames[0])
{
// process
}
else if (name == vNames[1])
{
// process
}
}
|
|
Supported
reference
SvsDump
SvsGetActionName
SvsGetEventTime
SvsGetEventParam
AddExpression
DelExpression
DelAllExpression
|