I am trying to get the sum of a variable list of data in a table, but am unsure how to get the data into a list. I’m using a date range to specify the start and end of the list, but am unsure how to get the data into the list.
I’ve experimented with a few loops, trying to move up or down a column in the table, but nothing has worked so far. I know there is probably a very simple solution.
Here is a sample of something I tried, but am unsure how to finish.
start_date = event.source.parent.getComponent(‘Date Range’).startDate
end_date = event.source.parent.getComponent(‘Date Range’).endDate
minutes = system.date.minutesBetween(start_date,end_date)
table = event.source.parent.getComponent(‘invisible table’)
for row in range(table.rowCount):
values = table.getValueAt(row, start_date)
final_value = system.math.sum(values)
event.source.parent.getComponent(‘Numeric Text Field’).intValue = final_value
In addition, I am wondering if it is possible to prune a historical tag in a database at a different rate than the prune rate set in the gateway for tags in general. The whole purpose of what I am trying to do is to find the total gallons through a flowmeter over a period of time, say 12 hours. The flowmeter reads in gallons per minute, but the flow may change multiple times over a minute so I want to sample more often. The number does not need to be exact, so I created a new tag that samples every second, and then takes the average of the last 60 data points every minute and saves the values to a table. The whole purpose of this though is to have the historian tag that samples every second save only very recent data, say an hour or a day, so that less disk space is used.
My apologies if this has already been covered or is a very simple question, I am new to Ignition and am struggling to find a resource.
Thanks for any help