Array, List, Dataset Datatype Conversion in Ignition

I apologize for being a noob but I am really struggling using the table object in Ignition. Right now I have a real array in my PLC that I would like to manage and add/change values from Ignition instead. Actually there are two arrays and I want to index them with a 3rd column 1:100. However, to test this functionality I was just trying to drag and drop my array into a column of the table object (everything is so easy in Ignition, why would this not work, I thought).

Ignition doesn’t treat my Real[100] datatype as an array, but rather a folder. Thus, it is looking like I need to do some scripting to system tag read from the array, and writing to a new memory tag set up as a float array, but I am not sure what the syntax looks like for writing to an array. I could do it value by value (dumb), or loop it over an index with a for loop or something but I still assume there is an easier way to do this.

A general question surrounding scripting, when/where do people call these types of tag creation scripts that don’t have a logical trigger? Do I run a startup script, or is there an event trigger that is sort of generic that makes sense?

Then once I have these arrays created, is there an easy way to create a dataset that I can just bind to the “data” property of the table? Alternatively is there a dataset write system function where I can write things column by column? Where would a fella’ fire this script?

For the most part this data is static but needs to be exposed to the HMI to facilitate adding additional rows via an HMI, so now i have 3 different 100 length real array with ~70 0s that eventually I would like to fill in with additional data as we add parts. It is a sort of a recipe table.

I am sure what I am looking for is relatively simple, but I can’t find a specific use-case that is exactly the same.

I’d recommend taking a look at templates and the template repeater (good training videos on Inductive University). This will make everything much easier to deal with instead of trying to convert back and forth from a dataset.

1 Like

I may be wrong, but this seems unnecessarily manual for large arrays/datasets. I see the utility in creating a parameter table like in the example, but really I think what I am after is a bit different.

The template repeater is great at handling large arrays. Say each element in your array has a couple float values, value1 and value2. You can create a single template with two Numeric Text Fields that are indirectly bound to each float tag in the array. You would have an “index” custom property on the root container of the template and use that index in the Numeric Text Field indirect binding to point at the proper array element. Now you can use the template repeater with this template, set the repeat count to 100 and you should see the template repeated 100 times to show your entire array in the repeater with the text fields pointing to the proper tags.

Maybe I misread your post and you are trying to do something different? Are you trying to update all values at once rather than trying to give the user the ability to update each individual value?

1 Like

I have a solution for you, how to bind a array to a PowerTable.

First, you need an expression binding to the “Data” property like this:

runScript("self.fillDataset", 0, tag("tag/path"))

then, you need the fillDataset script on the table itself:

def fillDataset(lArray):
    return system.dataset.toDataSet(["MyHeader"],[[value] for value in lArray])

and some changes in the Extension Functions:

  1. isCellEditable check Enabled
  2. onCellEdited check enabled and use the script below
import system
system.tag.write("tag/path[%d]" % (rowIndex), newValue)

You can make some tweaks to split up the one column to more, so you got a nice dataset, writing back to an array. You can also put the tag path in a custom property.

1 Like

Thanks for clarifying. I think this may work, but I guess the point I was making is that this is outside of the built in table functionality (unless I am missing something). As powerful and as Ignition is, it is surprising that you can’t just bind a column in table directly to an OPC tag array.

I submitted a feature request to this end… sometimes not all data is queried from DB, and so a way to bind arrays to tables directly without having script triggers and scripting would allow you to easily display live values directly in a table. For now the template repeater is just fine, it just seems odd that no-one has run across this specific use-case and wondered why binding a dataset is necessary when you have columnar data you could bind 1:1 with a column in an Ignition table.

1 Like