Version:

This lesson is part of the Perspective Components and Bindings course. You can browse the rest of the lessons below.

Supplemental Videos

LESSON

Passing Tag Paths to a Popup

Description

Learn how to pass a tag path to a popup view and use that tag path to construct indirect tag bindings.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] In this lesson, I'll demonstrate how to pass a tag path to a perspective view to dynamically display live tag values. This can be done with any kind of tag, but on my gateway, I have some UDTs in my tag provider that represent different stations with tags that I want to visualize in a pop-up view. I want to use this one view and have it dynamically display my tank level tags for the station I choose to display. I'm going to copy and paste the tag paths of tank one for stations one and two to demonstrate how similar these are in my tag structure. You can see that they're almost identical except for the station number. If I pass the beginning of my tag path up to the specific UDT, I can use that to dynamically build a tag path with a hard coded string for the rest of the path. I'll show you what this looks like in a minute. The first thing I need to do to make this dynamic is to add a parameter to my pop-up view. I'll make sure to select the view itself as opposed to the root container, and then I'll find the parameters section of the property editor and click add view parameter.

[01:03] I'll name this "tagPath", and then I wanna make sure that this arrow is facing to the left as this makes sure that this is an input parameter, or in other words, this value is expected to be set from somewhere outside of the view. I'm gonna copy the first part of the tag paths we looked at earlier, and I'll copy up to station one and paste it into this parameter. This will let me test out the rest of the view as I build my tag bindings. Next, I'll add the tag bindings to the vessel values. So I'll start with tank one. This is a tag binding and I want it to be an indirect binding, so I'll click that radio button and then to help build this out, I'll click the tag icon to select an example tag as my starting point. So I'll drill into station one, tank one, and then level. If I check out the binding preview at the bottom of the page, I see that this will end up displaying a value of 52, which is what I want. However, I want to use the tagPath parameter that I just created, which already contains the first part of this tag path up to tank one. So I'm going to delete this first part and then click the property icon to insert a reference into the path.

[02:04] The param is on this view in the params folder, and then it's tagPath here, so I'll click okay. This ends up showing me the value of 52 again, which is good, so I know the tag path was built correctly. However, this should now be dynamic and display tank one levels for other stations, depending on what ends up being passed to the view parameter. So I should be able to go back to the view parameters and update this parameter. If I change the tag path to point to station two, I end up seeing the level for tank one in station two. I'll set up a binding for tank two as well. This will be the same steps, so I'll make it an indirect tag binding, pick a tank two level tag, and then substitute the first portion with the tag path param. Now the pop-up view is ready to dynamically display tank one and two levels, depending on the tag path that's passed to it. The last step is to add some way to pass the parameters to the view.

[03:03] I'm gonna do this with a couple buttons. For the first button, I'm gonna right click and go to configure events. Then I'm gonna choose the onActionPerformed event and add a popup action. My view is called "Popup", and I'm gonna click the plus icon here to add a parameter. Any available parameters should show up, so I'll go ahead and click tagPath. And then for the value, I'm gonna paste the same string that I manually entered into the param to test earlier. Then I'll click okay. For the next button, I'll replicate the same exact steps, except this time I'm gonna pass the tag path for station two, and then I'll click okay. Now I'll make sure to save, and then I can launch a session and test my work. I'll click the button on the left to pass the station one tag path to the popup view, and I can see the tank levels for station one.

[04:02] Then I'll close the popup and click the other button to pass the station two tag path. And now I can see the values for station two. I can also update the tag from the tag browser to confirm its polling live values. To summarize, I created a view param on my popup. I referenced that parameter in the indirect tag bindings on my components, and then passed a value to the parameter when I open the view. Now I have a single popup view that dynamically displays live values based on the information that's passed to it in the runtime.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.