Reading tags and creating a table - VISION

Hello everyone, I am reading tags and these tags are visible in a label but I want to save every data in a table to see the all numbers that I am receiving in my label or saving everything in an auxiliar String and then print the list, can anyone help me whit this?.
Thank you so much.

Do you want to keep the labels, or only have the table ?

In the table will be better

Something like that ?

return [{'tag': path.split('/')[-1],'value': tag.value} for path, tag in zip(paths, system.tag.readBlocking(paths))]

How can I add a binding?, in the properties table says NO BIDING

You may want to watch the tutorial and read the doc…
https://docs.inductiveautomation.com/display/DOC80/Bindings+in+Perspective

But I am working with VISION, it is the same?

And how will be in labels?

Oh I’m sorry, I keep messing up my forum filters… I don’t know anything about vision.

Don’t worry and thank you so much

You could certainly replicate the given solution in Vision. Since script transforms are Perspective exclusive, to do that I would probably utilize the runScript expression function and the Script Library.

Here is my simple example:


You would just need to modify the ‘paths’ variable to be your list of tag paths and ‘headers’ to be the headers you want the table to display.

2 Likes

But how I put the tag or how I can reference the tag to the table?

You create a dataset, then pass that dataset into a table component.

Or you could even turn on history for tags and put them into a chart.

What kind tags are are you using? (i.e. stings, ints etc…)

are you logging just for visual, reporting, etc…?

I just want to save the numbers into a table, the tag is OPC

If you want to save the values of a tag to a database table, use the tag historian.

An easy way to display the saved values is with the table component using the tag history binding.

You can just enable history on those tags, and use a table, then filter that table to only show those tags.

Do you want to record to the time “infinitely” or just last 30 minutes etc…?

You have to remember that a Table Component is not the same thing as a Table Structure in a database. One can exist without the other.

However, @kelliot did answer your question as you asked it.

How do you read a tag?
system.tag.readBlocking()

How do you put those values into the table?
system.dataset.toDataSet()

The script and expression do exactly what you asked, they read a tag or group of tags value/s, create a dataset, and set the tables Data property equal to that dataset.

@Troy and @andrews have answered the question that we believe you are actually trying to ask.

How do I save the values of a tag/group of tags over time and then display them in a table component?
That is done by either using the Tag Historian, Transaction Groups, or if your trying to make it real difficult an insert query.

I found why did not work but there is an error : error executing expression binding on projectTags.root Container.Table.data

And now says:
File: , line 5 , in buildTable
IndexError: Row 0 doesn’t have the same number of columns as header list

The code that I have is:


def buildTable():
paths = ['[default]id', ['[default]tag']
headers = ['id','tag']
values = [val.value for val in system.tag.readBlocking(paths)]
return system.dataset.toDataSet(headers,[values])

Nevermind, I got things all wrong

I agree it’s probably not exactly what they want, but toDataSet() needs a list of lists. Each list must have the same number of values as headers.

I don’t think either example you provided actually does that.

@Esme_Lopez
How are ‘id’ and ‘tag’ related?