Description

Learn how to create a basic template in Ignition. You can then create multiple instances of this template throughout your project.

Video recorded using: Ignition 7.7

Transcript

(open in window)

[00:00] In this lesson we're going to learn how to how to create a basic template in Ignition. The template that I want to create is this graphic that I've made on the screen here, which is actually two different Ignition components. The top is a simple factory graphic, that I've actually cut out a part of so I can see through to the level indicator that's behind the scenes. When they're on top of each other here, it actually looks like I've created my own custom tank. That's different than the cylindrical tank that Ignition provides. To I want to create a template out of this so I can define all this in one place and use it many times throughout my project. So let's go up here in the top in the project browser and right click on the templates folder to create a new template. And right click to rename this template, I'm going to call it 'my tank'. Now, every template you create has to have at least one parameter, which is a property that will get exposed on the window so that we can bind that to a tag or to a calculation or to a query. So we can right click on the checkered area of the template, go down to customizers, custom properties, to identify all the parameters we want on the template. There are two areas of parameters, template parameters at the top, and input internal properties at the bottom. The ones at the top you actually get exposed to user on the window, whereas the ones at the bottom, they're only used within the template itself and you can't see 'em anywhere else. So I want to add a template parameter at the top. I'm going to click on the plus icon at top right, I'm going to call my parameter 'value' and the data type here, I want mine to be integer, but you can specify whatever data type you want. There's also this drop target here, let's go ahead and check it, and I'll talk about what that's going to do in just a second. Let's go and pres OK, and I'm going to go back to my window, I'm going to copy and paste these two graphics that I've made, and actually cut them and put 'em inside of my template, make my template little bit bigger, I'm going to paste 'em inside. Now when you're creating templates, it's really important that you don't want them to have all this dead space. So you want to nudge 'em right up against your component, so it's only that size. Last thing you have to do, is actually link the level indicator to the parameter of the template. If I don't link it, they'll never get to see the value that I linked to a tag inside the template. So I'm going to go here to my level indicator, come down to the value property, I'm going to bind it to a property which is going to be the template parameter that I added, called 'value'. And go ahead and press OK, and now my template is done. I can use it on any window. So I'm going to go ahead and click on the X down there to close the template, to save it. And then now I can actually drag it onto window. So I can take this, 'my tank', drag it onto my window, and now you'll see the graphic, I can drag it on multiple times. At the bottom you'll see a parameter here called 'value' that we can bind to a tag or to a calculation or to a query. I'm going to go ahead and bind mine to a tag, I'm going to go here and select N7:0, press OK, and I'll start seeing the value come through. Now you remember earlier, I selected the drop target check box of that template. And that's a really important one because basically you're saying that that is the property that I would like to link a tag to. So we use that property on the drag and drop system. So if I take N7:0 tag, and I drag it onto the window and I let go, it asks me what I want to do with that tag. And of course, I can create display components and control components that come with Ignition, but if I go down to templates, you'll see that my tank shows up in this templates area. And that is because the data type of that property matches the data type of the tag, so we can actually automatically bind that to the tag for you. So if I click it, you see that it's on the screen, and it's there for me. If I go down to another tag, let's say I go down here to another level tag, I drag it onto the screen and I go down here, templates, and say 'my tank'. You'll see that that one, of course, has a different value. So I can use this template many times throughout my system. If I ever want to change it, I can go back to the master, make a change, and it'll be there everywhere.

You are editing this transcript.

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