The script language

This article explains how to write a script using the script language. If you are looking for information about how to navigate around the script editor page, it is suggested you read Using the script editor.

 

 

The calculation consists of references to the aliases of the sensors added in the sensor list at the left side of the screen, coupled with a reference to the time "[t]" and the equation, defined by the following operators:

Between two values:

For example:  2 + 3,   5 < 7

plus = "+"
minus = "-"
modulo = "%"
multiplication = "*"
division = "/"
booleanAnd = "&&"
booleanOr = "||"
equals = "=="
notEquals = "!="
lessThan = "<"
greaterThan = ">"
lessOrEqual = "<="
greaterOrEqual = ">="

For one value/expression:

For example:  sum(sensor[t-1,t]),   cos(5),    10^(sensor[t])

sum = "sum"
average = "avg"
max = "max"
count = "count"
sin = "sin"
cos = "cos"
tan = "tan"
asin = "asin"
acos = "acos"
atan = "atan"
abs = "abs"
e_exp = "e^"
ln = "ln"
exp10 = "10^"
log10 = "10log"
round = "round"
floor = "floor"
ceil = "ceiling"
latch = "latch"
sqrt = "sqrt"

More unusual options:

"if(predicate){}"                                       Example:     if(S1[t] < 3) {V1[t] = 6}
"if(predicate){}else{}"                              Example:     if(S1[t] < 3) {V1[t] = 6} else {V1[t] = S1[t]}

"sumif(value, predicate)"                           Example:     sumif(S1[t-1,t], S1[t-1,t] >= 80)
“countif(value, predicate)”                         Example:     countif(S2[t-1,t], S1[t-1,t] != 80)

 

For script examples, refer to the article: Script examples.

Have more questions? Submit a request

Comments