Sorting and moving tag values in a table

Hi, I am using Ignition version 7.9.18. I am trying to create a table that will have two columns (Rack Pos, Curing Time) and 21 Rows. I am using a script to create a dataset and want to link my tag values to that dataset. Also need to sort the rows based on who will have lowest curing time value (which goes from 45 min. to zero). I have created a basic script shown below but stuck on how should I add the real time updating tag values instead for strings and how should I sort them. Can somebody help me out please:-

We don't know anything about your tags, so it pretty hard to tell you how to use them...
Also, you tagged your post with "database". How are databases relevant here ? you never mentioned this.

As Pascal stated, we'll need a bit more info to better help you out. But this is how I would do it, and perhaps give some inspiration.

A tag structure to put the curing racks in one area. My exmaple has 5 racks with a description and a cure time value. Also, since tags are global, I added a datast tag to hold our results.


Using a Gateway Timer Script:

basePaths = ['[Test]Curing Rack/%d/Description',
             '[Test]Curing Rack/%d/Cure Time'

# Create the list of tags to read
tagsIn = []
for i in xrange(5): # Number of racks
	tagsIn.extend([tag%(i+1) for tag in basePaths]) 

# Get the tag values
valuesIn = [tag.value for tag in system.tag.readAll(tagsIn)]

headers = ['Rack Pos', 'Curing Time']
# Split the flat value list into a list of lists.
data = [valuesIn[i:i+2] for i in xrange(0, len(valuesIn), 2)]

dataset = system.dataset.toDataSet(headers, data)

# Write the sorted dataset to the tag.
system.tag.write('[Test]Curing Rack/Dataset', system.dataset.sort(dataset, 'Curing Time', False))


Then, just bind the table to the dataset tag.

Hi Pascal, I haven't created the tags yet but I will try Jordan's method now. The plant where I am working at has a database called Igear. I was thinking of doing the table and sorting in the database and then just doing a query in ignition to display the table. Not sure if this method will even work. I am pretty new to Ignition so please bear with me.

Hi Jordan,
Thanks for your help. I will try your method with tags and script and hopefully I will make it work.

It seems to me you're not sure about where your data should go (tags, database...)
What's the source of the data ? Does it come from PLCs ? From an API ?

If you can tell us a bit more, we can help you chose between tags and database.

1 Like

The data comes from the PLC (Allen Bradley). The tags in the PLC are integers global tags.