How to create a 5000 element float array in UDT

It would be more efficient reading the values directly form the PLC, instead of making 5000 tags.

arraySize = 5000
#path convention in this example is Rockwell-ish
basePLCpath = '[DeviceNameInIgntion]path.to.float.array[%d]'
pathList = [basePLCpath % i for i in xrange(arraySize)]

valuesIn = system.opc.readValues("Ignition OPC UA Server", pathList)

t_stamp = system.date.now()

valuesOut = [] 
for i, value in enumerate(valuesIn):
	valuesOut.extend([t_stamp, i, value])

query = "INSERT INTO table (t_stamp, row, value) VALUES " + ','.join(['(?,?,?)'] * arraySize)

system.db.runPrepUpdate(query, valuesOut, 'dbConnectionName')
6 Likes