In a session prop change script I perform a series of
system.tag.queryTagHistory() operations. I then want to assemble these returns as a single dataset for a table. In reference to the pseduo-code below, I'm getting a type error when passing the return from
paths = sessionProp.paths names = sessionProp.names calcs = ['Count'] timeRange = -30 data1 = system.tag.queryTagCalculations(paths=paths, calculations=calcs, aliases=names, rangeMinutes=timeRange) timeRange= -1 data2 = system.tag.queryTagCalculations(paths=paths, calculations=calcs, aliases=names, rangeHours=timeRange) data3 ... data6 output = system.dataset.addColumn(data1, data2.getColumnAsList(1), 'Last Hour', int) # throws error: `TypeError: addColumn(): 2nd arg can't be coerced to org.python.core.PySequence`
I currently switched to a method like this, that is working:
columns = ['Tag Names', 'Data1 Column Name', 'Data2 Column Name', ... 'Data6 Column Name'] rows =  for row in range(data1.getRowCount()): c0 = data1.getValueAt(row, 0) # tag names c1 = data1.getValueAt(row, 1) c2 = data2.getValueAt(row, 1) c3 = data3.getValueAt(row, 1) ... c7 = data2.getValueAt(row, 1) rows.append([c0, c1, c2, c3, c4, c5, c6]) system.dataset.toDataSet(rows, columns)
I am just wondered if this is appropriate and what impact it may have on performance. Other tables I will be assembling will have 15 columns, and will be updated every second. Is there a better way to use the tag history system to collate various queries into a single table? There will be both 'live' tables and historical tables, and as far as I can tell the data in each column require unique parameters for their tag history query (different start and end times, different aggregation modes, and some using interval time slices while others look at the entire window).
At this time I cannot modify the PLC to produce data in the same way I need to retrieve it. As for setting up transaction groups, I would like to leverage tag UDT definitions and at this time I believe I can only configure tag history there and not transaction groups.