I’ve created a Power Table which pulls cycle time, the time of the completion of the cycle from a PLC (Allen Bradley CompactLogix). With running upwards of 400 parts a day, I’ve had to MANUALLY put the tags in the respective rows/columns. This means that I’ve had to sit down and copy, paste, and edit 1200 cells.
I have to do this for TWENTY lines. Ignition support has helped, but pretty much told me I’d have to do this to make it work.
Is there anyone that could clue me in on some scripting which would drastically cut my time of having to copy and paste tags in so many cells. I’m no Python expert, but there HAS to be a way I can put some scripting in that populates the Power Table off of arrays from the PLC without having to spend days copy and pasting.
I’m looking for something similar as well… I believe you should be able to add bindings to vision component objects via script, haven’t been successful in implementing as of yet – I’ll post my findings to this thread: PowerTable Binding via Script or Indirection Template? . It would be great if you could do cell update bindings for all rows based on a column value…
Based on this post by @pturmel – it sounds like you can get a list of/add new property/binding adapters from the window interaction controller… though I’m not sure of how dangerous this is… seems kind of hacky…
If I need to get data from tags and put them into a “table” format, I never use a table component. I always create a template that looks like a table row. I then use a template repeater to make it look like a table.
I find it easier to bind my template cells this way, and it gives me some more flexibility in presenting they data, say I need a drop down menu, it’s easier to use a template, then add a drop down component then it is to script the functionality in the power table.
On the row template, I have a generic “tagPath” property. I pass the tagPath here and let the bindings to do the rest.
Thanks @Paullys50! – this is definitely a good workaround, we’ve deployed similar in the past with good success. We’ve found that you can even embed your table header into the template and use the repeater vertical spacing controls (supply the negative value of your header height) to keep the header aligned/resize properly with the template repeater.
We like the option of the PowerTable, however, as it lends sorting/filtering capabilities that are more difficult to implement with the template repeater route.
I’m still hoping that we can add bindings to the PowerTable at runtime via script (see the linked thread in my post above RE: accessing the window interaction controller) – but as another workaround, IA has suggested that we create new PowerTable datasets explicitly via script (and execute via runscript) – e.g. do not create any tag bindings, populate the table values manually via a combination of system.tag.read() and system.dataset.toDataSet() functions.
There are a number of ways to do it.
Below is a simple example just grabbing one set of tags and writing to a dataset.
For a larger amount of tags you would just loop the read results and append records.
tbl = event.source.parent.getComponent('Power Table')
tblHdr=['Tag1','Tag2','Tag3','Tag4']
#Below does a system tag read for Ignition tags
tagsToRead=['[default]Path/To/Tag/1','[default]Path/To/Tag/2','[default]Path/To/Tag/3','[default]Path/To/Tag/4']
tagValues=system.tag.readAll(tagsToRead)
tblVals = []
nd = map(lambda x: x.value, tagValues)
tblVals.append([str(nd[0]),str(nd[1]),str(nd[2]),str(nd[3])])
tbl.data = system.dataset.toDataSet(tblHdr,tblVals)
#Below does a direct PLC read of the tags using the OPC Server
tblOPC = event.source.parent.getComponent('Power Table 2')
tagsToReadOPC=['ns=1;s=[PLC]Tag1','ns=1;s=[PLC]Tag2','ns=1;s=[PLC]Tag3','ns=1;s=[PLC]Tag4']
tagValuesOPC = system.opc.readValues('Ignition OPC-UA Server',tagsToReadOPC)
tblOPCVals = []
ndOPC = map(lambda x: x.value, tagValuesOPC)
tblValsOPC.append([str(ndOPC[0]),str(ndOPC[1]),str(ndOPC[2]),str(ndOPC[3])])
tblOPC.data = system.dataset.toDataSet(tblHdr,tblValsOPC)