Property Binding Types
A property can have one of many different types of bindings. Instead of setting a label statically, the text might change based on a PLC value or on-screen selection. There are many ways to bind your components to show values from PLCs, databases, other components, or user input. You can even bind some or all of the properties on each component. You can bind component values using:
- Property simply binds one property to another. When that property changes, the new value is pushed into the property that the binding is setup on.
- Tag binds a property directly to a Tag property (typically the value) which sets up a Tag subscription for that Tag, and every time the chosen Tag property changes, the binding is evaluated, and pushes the new value into the bound property.
- Indirect Tag is similar to the standard Tag binding except that you can introduce any number of indirect parameters to build a tag path dynamically in the runtime.
- Tag History is used for Dataset type properties. It runs a query against the Tag Historian.
- Expression uses the simple expression language to calculate a value which can involve lots of dynamic data.
- Named Query executes a Named Query that had been previously created.
- SQL Query is a polling binding type that runs a SQL Query against any of the database connections configured in the your Gateway.
- Database Browse is equivalent to the SQL Query binding except that it helps write the queries for you.
- Cell Update enables you to easily make one or more cells inside a dataset dynamic. This is useful for components that store configuration information inside datasets like the Easy Chart.
Function is a generic binding type that lets you bind a dataset property to the results of a function. It allows any of the function's parameters to be calculated dynamically via Tag and property bindings.
Style Customizer is not one of the standard bindings, but changes properties to create cohesive styles based on different states.
Setting Up Bindings
Every component that you put on the screen has various properties that change the component's appearance and behavior. To make components do something useful, like display dynamic information or control a device register, you configure bindings on the component. It's the bindings that brings your components to life and have them do useful things. Components can be configured to do just about anything using bindings. To set up a binding on a property, simply click the binding button () to the right of the property in the Property Editor.
In this image, bindings were set to make these random components do something. You can quickly view dependencies to determine what is linked to what by going to View > Dependencies > Show All. As shown below, a line is drawn from the Slider to the Tank letting you know the Tank is bound to the Slider.
How Bindings Work: Event-based vs. Polling
While there are quite a few different binding types, they all boil down into two broad categories: event-based and polling. Some complex bindings can span both categories.
Event-based bindings are evaluated when the object they are bound to changes. For example, when you bind a property to a Tag, that binding listens to the Tag, and every time the Tag changes, it assigns the Tag's new value into the property that it is on. If you bind the value of a Cylindrical Tank to the value of a Slider, every time the slider changes, it fires a propertyChangeEvent. The binding is listening for this event, and when it is fired, the binding updates the tank's value. The following bindings are event-based:
- Tag and Indirect Tag bindings
- Property bindings
- Some Expression bindings
- Cell Update bindings
Polling bindings are evaluated when a window first opens, on a timer, or when they change. For example, if you bind the data property of a Table to the results of a SQL query, that query will run on a timer, updating the Table every time it executes. The following bindings are based on polling:
- Bindings that query a database, including Named Query bindings, DB Browse bindings, SQL Query bindings, and Tag History bindings
- Some Expression bindings, like runScript() or now()
- Function bindings
Many bindings can combine elements of a polling binding and event-based binding. An expression binding may combine lots of other bindings to calculate a final result. A query binding will often itself be dynamic, altering the query based on other bindings.
For example, you might have a dropdown on a window that lets the operator choose a type of product that is produced. Then you can use a query binding like the following to calculate the defect rate for the given product:
The blue code is a property binding inside of the query binding. Every time this (event-based) binding fires, the query will run again, but will also run on a set timer based on its polling schedule. Using bindings like this, you can create highly dynamic and interactive screens with no scripting whatsoever.
When you copy a component, all bindings, scripts, etc. are copied along with it, but you can also copy a property binding from one property to another. Bindings can be copied from one property to another by right clicking on a property with a binding on it and selecting Copy Binding. Then, on another property, right click and select Paste Binding to paste the binding onto the property. This can be on the same component or a completely different component. The only prerequisite is that both property bindings must use a compatible property type. (i.e., A binding that resolves to a string will not work on an integer property, etc.).