Populate a table with OPC tags

I have a project in Vision 8.1, in this project i have a table Vision which has in the rows 20 devices with similar characteristics and in the columns, 2 columns that will reflect electrical variables of each of the devices, for example from device 1 to device 20 I want to see the active and reactive power in the table. of each team. The tag path of each electrical variable is similar for all devices, only a number that identifies the device varies, for example:

For the first electrical variable:
Equipment 1: [default]INVERTER/Inverter 1/MEASURE/INV_P_TOT_W
Equipment 2: [default]INVERTER/Inverter 2/MEASURE/INV_P_TOT_W
.
.
.
Team 20: [default]INVERTER/Inverter 20/MEASURE/INV_P_TOT_W

For the second electrical variable:
Equipment 1: [default]INVERTER/Inverter 1/MEASURE/INV_Q_TOT_W
Equipment 2: [default]INVERTER/Inverter 2/MEASURE/INV_Q_TOT_W
.
.
.
Equipment 20: [default]INVERTER/Inverter 20/MEASURE/INV_Q_TOT_W

How can I populate the table dynamically, taking advantage of the fact that the OPC TAG path is very similar for all devices. I hope for suggestions, if it may be possible to use the features of the Vision Table, or use Template Repeater.

Thanks in advance

If you're looking to use a table, then something like this should work. Point the table to the tag, update the tag using a gateway timer script.

def chunker(seq,size):
	return(seq[pos:pos + size] for pos in xrange(0,len(seq),size))

baseTags = ['[default]INVERTER/Inverter {}/MEASURE/INV_P_TOT_W', '[default]INVERTER/Inverter {}/MEASURE/INV_Q_TOT_W']
tagList = []

for i in xrange[20]:
	tagList.extend([tag.format(i+1) for tag in baseTags])

values = [qval.value for qval in system.tag.readBlocking(tagList)]

headers = ['Inverter', 'P_Power', 'Q_Power']
data = [[i+1]+row for i,row in enumerate(chunker(values,2))]

system.tag.writeBlocking(['[default]path/to/tag'], [system.dataset.toDataSet(headers, data)])

If using a template (and you should), use the inverter number as a parameter, and bind the display components tags using indirect addressing.

Thank you very much Jordan for the answer, sorry for the late response but I am currently in a field commissioning of equipment

1 Like

No worries. Been there.