Sampled calculation examples
Add 2 variables
return _A.Value + _B.Value
Select variable based on condition
if _A.Value > 100.0 {
return _B.Value
} else if _A.Value < 100.0 {
return _C.Value
}
return _A.Value
Raw calculation examples
Map value to string
if _A.Value == 1.0 {
return "STEP_A"
} else if _A.Value == 2.0 {
return "STEP_B"
}
return "INVALID"
result := text.re_find("\\\\d+\\\\.?\\\\d*",_A.Value) // eg _A = "SOME_2344324.34_VALUE"
if result != undefined && len(result) > 0 {
found := result[0][0].text
return float(found)
}
Return elapsed time between previous and current value
previous := local.get("previous")
local.set("previous", _A)
if previous {
return times.sub(_A.Timestamp, previous.Timestamp)
}
return 0