Description

Learn how to use retargeting to switch between projects on the fly.

Video recorded using: Ignition 7.7

Transcript

(open in window)

[00:00] In this video, we're going to talk about retargeting. Retargeting is really one of the most powerful abilities of the visual module that a lot of people are not aware of. Retargeting let's you take a running vision client and retarget it to a different project, potentially on a different gateway. So this lets you not only just break up your projects by logical grouping on a single gateway, which can be great for maintenance, but it also let's you create a seamless SCADA system across multiple gateways by having clients retarget around multiple gateways. Even across WANs into different facilities. A very powerful ability that is achieved through some very simple scripting. So I have two projects set up here, project A and project B. And all they do is retarget to each other. So let's go ahead and see this in action and then we'll look at how it works. So I'm logging in to project A here. Here we are, in project A. And we've got a button to retarget to project B. And now in this case, project B is on the same gateway as project A. So we click the button and that's it. We've now retargeted and the client is running project B. And from here, of course, we can retarget back to A. Now, you'll notice that we didn't have to login to Project B. That's because projects A and B both share the same user profile. And the retarget feature let's you forward your credentials that you used to login to Project A, it seamlessly forwards those credentials over to Project B. Now if those credentials didn't match, or Project B was using a different authentication profile, the retarget would make you log back in to the target project. Now let's switch back to the designer to see how this is done. And we can get a little bit more advanced by passing some parameters through the retargeting process. So we can see how this works here in this button. It's got a single line of script in it. It just calls retarget from system.util with the name of the project. Now of course, if we were trying to retarget to a project on a different gateway, we would need to give it the gateway address which is in a special format. Where it's the host name or IP address and then two ports. The standard port and the SSL port/name. Now, there's two other parameters that we can give retarget as well. One of them is a dictionary of parameters. Just any arbitrary name value key pairs that you want to pass into the target project which will be accessible via global variables. As well as an optional sequence of start up windows. So, normally when you retarget to a project, it will start up the project's standard set of start up windows. But if you give it this list of start up windows instead, those windows will be opened. Let's go ahead and use the parameter dictionary, and we can demonstrate just how we can pass any arbitrary information over to the target project. So, since I'm retargeting to a project on the same local gateway, I can just skip this parameter by passing it none. And then I'm going to just make up a name here, we'll call it test param and it'll be equal to 15. So this is a dictionary with a single key value pair in it. And this information will be passed to the target project as global scripting variables which we'll look at how to read in just a minute. Let's hit okay and save that. And then we're going to open up the retarget B project so that we can consume those global variables. All right, so to read the test param in Project B, what I'm going to do is I'm going to add some scripting to the main window itself. And you can see that one of the event types that Windows have are these vision window event. And we've got vision window, open vision window, close. This is a good way to run a script when the vision window is opened. And from here, I want to read the test param out of the global variables. And so, to get the global variables, I call system.util.getGlobals. And that's a dictionary. So I can just reference test param like this out of it. So that's going to pull that value out of the global dictionary and then we'll just throw it on a label. So, I have a, let's put a label on the window for this purpose. So let's throw label right there. And it's called label. So, if I go back to my script, I can grab that label. So label is equal to event.source, now event.source, in this case, is the window. So I need to get the root container. And then from there, I call get component... label. And then I can just say label.text is equal to the string value of the value. All right. So that should, when the window's opened, pull our parameter that we sent to Project B from Project A through the retargeting mechanism. So let's go ahead and save that one. We'll go back to our client here and update it. And when we retarget to B, you can see that our parameter was pulled out of the retargeting global variables and thrown onto that label. So that's about it for vision client retargeting.

You are editing this transcript.

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