[00:00]
In the previous lesson, we looked at how we can create UDT instances by hand, in much the same way we would create any other tag type. While that approach was straightforward, it did require some manual effort to set up our instance, a couple of clicks of the mouse and a little typing. Of course, if you're accustomed to working with hundreds or thousands of tags, you know that even just a couple seconds of mouse clicks and keyboard input can really add up over time and anything we can do to automate the tag creation process could pay dividends in development time while staving off human error. In that spirit, we'll take this lesson to explore a competing way of creating UDP instances designed for scale and ease of use. We'll be using a tool called the Multi-Instance Wizard which simply put, allows us to spin up many instances of a UDT in a single action. Now, the first step as in our last video is to have a UDT definition created. We'll be using the sensor UDT we made earlier in the series. Since we already have that, we're ready to get our instances up and running.
[01:05]
To pull up my multi-instance wizard, I'm going to begin by finding my tag browser and right clicking wherever I want my new instances to live. If I right click on a tag in the root folder of my provider here I can put the instances right at the roots but I have this nice little sensors folder set up already. So if I right click on that folder, I'm just going to select the Multi-Instance Wizard. And as my wizard comes up I'm going to make it a little bit larger. Now there are two parts to working with the Multi-Instance Wizard, in step one here we select a data type to use for our instances. Since I only have the sensor data type that will be selected automatically. After that step two here is the real heart of the interface. What we do is decide how we want to name our instances and also what parameter values we'd like to pass to them. We'll begin by specifying our instance names and we have two fields here for that. I think I'd like the names for my instances to be sensor one, sensor two and so forth. So they'll all start with the word sensor and then have a number at the end that will need to be specific to each instance.
[02:06]
This interface happens to be set up perfectly for that format. The base tag name field here lets us specify a starting set of characters that all of our instance teams will share. So here I'll just type sensor and now we're ready for the more complicated bit. The number at the end of each of our names, for this will need to be tag name pattern field here. This allows us to configure a dynamic piece of the tag name and it accepts a few different formats which we can see in our little box here at the bottom. One of the options is a range pattern which just allows us to specify a numeric range like one to 10 or zero to 99. This actually works perfectly for us here because we have three centers total and I just want them to be numbered one to three. So in my tag name, pattern field I'll just type one dash three. I can include a step size if I want the pattern to be something other than sequential numbers. Though I won't be needing them here. There are two other patterns available as well.
[03:03]
The list pattern allows you to type out a comma separated list of values to use. And the repeat pattern just allows you to use the same value for as many instances as you specify. As the note suggests here, you can also mix and match the range and repeat patterns inside of a list pattern. So with that said, our work isn't quite done yet. We have our names set up the way that I'd like but I also have a UDT parameter that each of my instances needs to have populated. If you've been following along with our UDT videos, you know that the SensorNum parameter is driving the OPC member tags in our UDT and it's essential that we populate it correctly. Each of my UDT instances is going to need a different value here. Sensor one should have a value of one. Sensor two should have a value of two and sensor three should have a value of three. To do that all I need to do is find my pattern field here for the parameter, double click to enter the cell and type one dash three again, the same pattern our name uses. Once we do that, the interface is smart enough to know that we'll be creating three instances so it shows the size as three.
[04:05]
Now, if I were to click okay here, our instances would be spin up right away. But if I want to check my work before I create the tags I can hit the preview button in the bottom left. That'll show us the tag names and parameters for using, for our created instances. And in fact, looking at the preview here, if I want to put a space character between the word sensor and the number for that sensor, that isn't too hard to do. If I click the back button here and go back into our configuration, I can just find the base tag name field and I add a space at the end. And that's it. So now if I click, okay I can find my sensor's folder in the tag browser, expand it and we'll find three new instances. Browsing through them, we'll see that they're complete with different values on that SensorNum parameter. That's all there is to using the Multi-Instance Wizard. It's a great way to create many UDT instances at once with just a few clicks.