I’ve recently finished my course in Eletronics, Automation and Instrumentation and for the first time i’m creating a SCADA project using Ignition.
I’m experiencing some issues with my project… I wan’t to create a daily Report and i wan’t to make a table with all the hours of a day, for each hour i would like to have the average of a real time value, for example:
I have a Sensor measuring all day and in the Table, i would like to see the average value (in the Tab “Concentração CO %”) for each hour. But the problem is that i can’t figure out any way to do that expecific average. I already searched alot, i tried creating parameters with expression binding (Date and Time) and then add my Historical Tag but it still doesn’t do what i want.
Thank you for your help, and sorry for my bad english by the way. :b
This got marked solved, but since no solution was posted, I’ve unmarked it to post a couple of suggestions that may help others stumbling onto this topic.
There are a number of ways that you can do what you want. Here are a couple that come to mind…
One would be to do your historical tag query for the whole day, but also use a script data source. Each data source has access to the data sources above it, so the script data source can calculate sums and averages for each time unit that you want. The docs show some examples of using previous queries in a script data source.
If you know that your time divisions will always be hour 0-1, 1-2, etc, you can break this into separate queries. I would populate a sql table with the hours that I want, and use that table as my top level query. Then I would nest tag calculation queries below it, using the top level query to define my start and end dates.
Hopefully someone else who’s had more caffeine will pop in here and come up with more suggestions…
you could try something like this in a report script
header = ['time', 'avg1', 'avg2', 'max1', 'max2', 'min1', 'min2']
newDataset = 
endTime = system.date.now()
StartTime = system.date.addHours(endTime, -24)
path = ['[DB]coffee/plc/Pre Extraction/2H20/2E23/PV',
rawDataset1 = system.tag.queryTagHistory(paths= path, startDate=StartTime, endDate=endTime, aggregationMode="Average", intervalHours = 1)
rawDataset2 = system.tag.queryTagHistory(paths= path, startDate=StartTime, endDate=endTime, aggregationMode="Maximum", intervalHours = 1)
rawDataset3 = system.tag.queryTagHistory(paths= path, startDate=StartTime, endDate=endTime, aggregationMode="Minimum", intervalHours = 1)
for row in range(rawDataset1.rowCount):
valTime = rawDataset1.getValueAt(row,0)
valavg1 = rawDataset1.getValueAt(row,1)
valavg2 = rawDataset1.getValueAt(row,2)
valmax1 = rawDataset2.getValueAt(row,1)
valmax2 = rawDataset2.getValueAt(row,2)
valmin1 = rawDataset3.getValueAt(row,1)
valmin2 = rawDataset3.getValueAt(row,2)
newDataset.append([valTime, valavg1, valavg2, valmax1, valmax2, valmin1, valmin2])
newDataset = system.dataset.toDataSet(header, newDataset)
data['Mydata'] = newDataset