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
Incremental counter
threshold := 100
previous := float(local.get("previous"),0.0)
result := previous + _A.Value
if result >= threshold {
local.set("previous", 0.0)
return 0.0
}
local.set("previous",result)
return result
Generate random float between 0 and 1
return rand.float()