Numeric Label to display current value minus the value from 1 hour ago

Hello everyone. I’m new to Ignition so please excuse the question if there is a simple answer. I’ve tried to see if there is a similar question or documentation somewhere but I haven’t been able to find anything yet.

I am creating a dashboard for operators on a manufacturing floor. This dashboard will give them various efficiencies and rolling averages or values over the course of 10 minutes, 1 hour, and 12 hours. For example, how many units were made in the last 10 minutes. I would do that by taking the current value of the PLC and subtracting the value from 10 minutes ago.
I would be doing this for a number of values, so I would rather not create tags for each of these values. I would like to do the calculation in a script and display the value in a numerical label. The calculation would be using only 1 PLC tag at a time.

What would be the best way to go about doing this?
To get the tag history I can use system.tag.queryTagHistory and select just the value that most closely matches 10 minutes ago and subtract that from the current value. How would I display that value? Where would I need to put that script? I tried putting it in the propertyChange component scripting, but I don’t know how I would then change the value displayed.

Thanks for your help. Looking forward to learning from you all.

  • Nathan

I would put two custom properties on the component: prevValue and currValue (or some other names you like). prevValue would use a tag history binding that would return the same value as the script in your post. currValue would be bound to the current value. The actual display property of your component (text, intValue, doubleValue, etc.) has an expression binding subtracting currValue from prevValue. This solution is all bindings, no scripting. I think that’s preferable where possible.

This did it! Thank you very much!
I made the two custom properties and then I made the prevValue property a dataset which pulled the data and then I took the first value that was the given time ago.