I have a level transmitter that reports the value in gallons per hour. I am working on a 1-hour, 12-hour and 24 hour average for this tag so we can determine usage for this material over those periods. My problem is how do I set up the calculation so that when the tank is filled during those periods I can adjust my numbers for the amount added. Right now if I use a simple equation like this:
TagAvg('LI-3050.PV','*','*-1h') or this Tagval('LI-3050.PV','*-24h')-TagVal('LI-3050.PV','*')
and the tank is filled during that hour then the average usage is incorrectly reported. I need to look at when the tank started to increase, track how much it increased and factor that into my average for that hour.
I am doing all of this in PI AF to keep the equations simpler and to allow backfilling of the data. I am assuming it will take an IF-THEN-ELSE statement but I am uncertain of how to set it up.