queryTagHistory and lack of data

Hi all,

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.

No one ?

paths should be a list of tagpaths.

system.tag.queryTagHistory( paths = ["sensor_path"], startDate = rpStart, endDate = rpEnd, returnSize = 1, noInterpolation = True, aggregationMode = "Average", ignoreBadQuality = True, validateSCExec  = True)

[quote=“jpark”]paths should be a list of tagpaths.

system.tag.queryTagHistory( paths = ["sensor_path"], startDate = rpStart, endDate = rpEnd, returnSize = 1, noInterpolation = True, aggregationMode = "Average", ignoreBadQuality = True, validateSCExec  = True)

Hi, in the code I’ve posted above I inserted only one element in the paths list, but in the real application I would use a list of about 10 elements. However, the list lenght should not affect the behaviour of the function.

The problem is that the function expects a list of strings, but in Python long strings are themselves essentially lists of individual string characters - so passing tagpath=‘String’ is literally giving the function the six tagpaths ‘S’, ‘t’, ‘r’, ‘i’, ‘n’, ‘g’. You have to wrap the string in square brackets to define it as a list so that the function sees it as one argument.

Oh I’m really sorry: I noticed only now that in my initial code the square brackets are missing… :blush: I made a mess when I copied the code since I’ve just checked the one I used for my tests and it is ok…
Back to the topic, do you have any suggestion to manage the missing data period? One of my main concerns is to find an efficient way to do it, since the calculation has to be performed (for each day) over the whole year…

Thank you