Speed Up Development Using Templates
Developing HMI and SCADA projects can be tedious and time-consuming, especially when they involve a high number of repetitive tasks. Copying and pasting components over and over again not only slows you down but also sets you up for problems in the future. Fortunately, there’s a better way to get your project done: templates.
What are Templates?
Templates are a powerful way to accomplish the same goal as copying and pasting, but in a fraction of the time. Using templates is a best practice in its own right, but templates are even more powerful when you really understand the different types and how to apply them.
This tip sheet will introduce you to three types of templates in Ignition and when to use each one, to help you get the most out of them. The three template types covered here are static, variable, and indirect.
Tip 1: Use Static Templates for Simple, Single-Task Components
Static templates are the simplest type of templates. They are basic components that always do the same task. You configure a static template once instead of configuring it repeatedly, and you always make changes to it in one place.
Example: Let’s say you need a simple button to use in your project. This button will only do one thing: link to the homepage. Even if you place the button in many different sections of your project, it will always link back to the homepage. By building this homepage button as a static template, you can configure it in one place instead of configuring it 50 times.
Tip 2: Use Variable Templates to Build Custom Components
The next step up from static templates, variable templates are like making your own component in Ignition. They are usually graphics that expose a simple property which can be linked to tags or any other data source. Variable templates commonly only have one parameter, usually a simple value like an integer or string.
You should use a variable template when you don’t want to specify how it will be used, but you want to make this combination of components in one place. You’re essentially making a component that anyone can use in any way they want.
Example: You can use a variable template when you want a customized graphic that displays a value that will change over time, such as a tank level. You make a component with a simple integer value, then link the template’s instance to a tag, query, or the like. What it’s linked to will determine the integer that fills the tank, and the template will determine the tank’s appearance.
Tip 3: Use Indirect Templates for Consistently Structured Data
When you’re trying to make a specific component, you would use an indirect template binding. This type of template points indirectly to a set of tags based on a simple parameter, such as an integer or a string. Unlike a variable template, an indirect template is set up to be used for a particular task. This is because you’re indicating within the template that the data it’s looking for is located somewhere in a particular data structure, and that structure is determined by the parameter.
Example: Suppose that you have a template for all of the motors in your enterprise. You’ve got 200 motors, and now you need to add motor 201. If you’ve organized your data consistently, you only need to add three tags (HOA, AMPS, and Motor Name) to each motor in order to use it. You can use the same template for all your motors, and only have to change part of the tag path. Keep in mind, however, that indirect templates will only work when your data is structured in a consistent way.
Save Time and Future-Proof Your Application
Using templates in Ignition can save you a lot of development time, and help you future-proof your application. The reality is, an HMI/SCADA project is never really finished. You will inevitably have to add components to the project in the future, and you’ll save a lot of time and effort in the long run if you spend the time up front to configure templates.
Recent Comments