I am trying to create a display that shows the values for a set of OPC tags selected from a Tag Browse Tree. I am able to show the path by binding to the "selectedPaths" property but I would like to show the path in a column, and then the value in a second column next to that.
I am guessing that there will need some type of scripting involved and am new to scripting but trying to learn. I have done a number of searches and have not been able to find a solution thus far.
Just FYI, I'm using 8.1.
Thank you for the help!
I added some tags to your post so it's easier for the right people to see. From the name of the property I assume you're using Vision. If that's not the case, please feel free to edit the tag.
Perfect, thanks for the help! You're correct, I am using Vision.
You're welcome! From the looks of it, you should be able to use a property change script on the tag browse tree that would check if the property that changed is
selectedPaths. From there, you could use the dataset functions (
system.dataset.getColumnAsList()) to turn that dataset of paths into a list, then use that in
system.tag.readBlocking() to get the values. You could then use a list comprehension to pack that into a list of [path, value] lists:
rows = [list(x) for x in zip(paths, values)]
and finally turn that into a dataset that goes into the table's data property (
system.dataset.toDataset(headers, rows)). Because it's relatively involved, I'd put all that logic into a library script that is called from the property change script.
Hopefully that lets you get started, and if you need clarification on any step we're here to help.
I would use a template repeater to show these values and every time the user selects a tag it gets added to the repeater by a propertyChange script that looks at the "selectedPaths" property.
First you would need to create a Template with Indirection.
Add a Template Repeater to your window.Using the template repeater, this would also be useful.
A good look at how Datasets work should tie everything together, i suggest you take a look at those links, try something out and if you have any questions, come back.