I am running version 7.3.4 of Ignition and I have the following code setup in my script tester environment:
[code]from java.util import Calendar
from java.util import Date
startDate = Calendar.getInstance()
startDate.set(2012, 9, 1, 0, 0, 0)
startTime = startDate.getTime()
stopDate = Calendar.getInstance()
stopDate.set(2012, 9, 1, 23, 59, 59)
stopTime = stopDate.getTime()
returnSet = system.tag.queryTagHistory([’[history]H2O/Well07/Flow/PV’], startTime, stopTime, 1, “Average”, “Wide”)
print returnSet.getValueAt(1,1)
[/code]
I have run this code several times - with no changes - and only seconds apart. I ran this code last night against a date of 10/1/2012 so there is no new data being logged. Here are my results:
1214, 1223, 1212, 1216, 1220, 1221, 1219, 1214, 1216, 1221, 1215, 1222
Any thoughts on where the variance is coming from? They are all in the same ball park, but it doesn’t make sense that the same calculation against the same set of data would result in different answers.
To make things even stranger, if I modify the code in the following way:
for loop in range(10):
returnSet = system.tag.queryTagHistory(['[history]H2O/Well07/Flow/PV'], startTime, stopTime, 1, "Average", "Wide")
print returnSet.getValueAt(1,1)
I get exactly the same answer for each iteration in the loop, but each time I run the entire code sample I get a different answer for the loop. The first time I got 1220 for ten iterations. The next time I got 1222 10 for all ten iterations and so on and so forth.