I am having some issues with the history querying and I would ask your help.
Starting from the history of a tag (power), I need to calculate its integral (energy) over a reference period “rp”. I am currently using the “system.tag.queryTagHistory” function to calculate the time-weighted average over rp, then I multiplicate the resulting value for the rp length itself (hours). This return Wh.
However, I am having some troubles when there is a lack of data inside rp: the average resulting from the function call seems to not consider the missing data period, then multipling for the rp duration is not correct…
To solve it, I see two possible solutions (but I can’t figure how to do it in a smart way):
- force the system to consider as 0 the values of the tag during the data missing period
- calculate the net rp duration ( rp - lack_duration) and use it to calculate the energy
My function call is (I’ve tryed also different configurations but with no luck):
system.tag.queryTagHistory( paths = "sensor_path", startDate = rpStart, endDate = rpEnd, returnSize = 1, noInterpolation = True, aggregationMode = "Average", ignoreBadQuality = True, validateSCExec = True)
I am working with Ignition 7.8.3.
Any suggestion would be really appreciated.