Hello,
I am trying to track machine uptime via tag history. I have seen quite a few posts about this type of tracking, but none seem to reference this tag history. Based on what I have read, this setup should allow me to use code similar to what is pasted below. The end goal is to build a custom data set for a report over a 24-hour period with a returnSize=24 . Like I said, this seems to be a common topic, but I have yet to see one that deals with my issues with the DurationOn aggregation.
starttime = system.date.setTime(startdate, 10,40, 0)
endtime = system.date.setTime(enddate, 11, 00, 0)
qdataset = system.tag.queryTagHistory(paths=['Tag'], startDate=starttime, endDate=endtime, returnSize=1, noInterpolation = True, aggregationMode="DurationOn", returnFormat='Wide')
uptime = qdataset.getValueAt(0, 1)
# Using the range function, we can come up with a range of values that represents the number of columns.
for row in range(qdataset.getRowCount()):
for col in range(qdataset.getColumnCount()):
# Will print out every item in our dataset, starting on the first row and moving left to right.
print qdataset.getValueAt(row, col)
I can see the data properly populating in my table, and aside from the first 10 records which I assume are some sort of initialization, I am seeing records for each “On” and “Off” of the boolean bit I am toggling. I have it programmed for 50 seconds on and 10 seconds off so that I have a predictable result. If I use the “CountOn” aggregation for a duration of 20 minutes I get a result of 19, which is believable if the PLC 20 minutes is not perfectly sync’d with Ignition’s 20 minute window, but when I use “DurationOn” I get a result of 18… If I change the returnSize=10, I get 18, and then a bunch of zeros instead of the same duration for each period. I am using the print to see my results in the debug window.
Is there something that I am missing. Sorry for the long post, but I wanted to get as much information up front as possible. Like I said, it is only the DurationOn function that is causing me confusion.
Thanks