I have some tags being populated from a device. I would like to create various moving window average based alarms - e.g. if the average value in the past n minutes is outside some setpoints, raise an alarm. I’m looking at implementing this for a wide variety of tags, for a wide variety of window sizes.
I can do this with gateway scripts, but I’m not sure if that’s the best way. Are there any other techniques I could use for this?
I would be using my objectScript expression function (from my Simulation Aids module) in an expression tag, using it’s
state variable to hold recent history in a fifo for fast computation. The alarms would then be set on the expression tag as usual.
Thanks for the suggestion, I’ll try it out and post how I go!
Did you manage to implement this ?
I’ve got the exact same request…
Try this script:
Requires my Simulation Aids module, linked above.
I was curious how I could do it using base ignition, and what I came up with was:
- Create an expression tag referencing the current time (updating at the frequency you want to update data).
- Create a change event which logs the data you want to another tag (in this case, it runs a
queryTagHistory using the window size to get the average in that period).
- If you historise this other tag, you get a history of moving window averages.
I don’t think this would scale well, but my use case was for a few tags in a very small system, but used across multiple different systems.
For any real production system, I would assume the solution proposed by @pturmel is much more performant.