You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing email@example.com.
We are experiencing playback issues from our video hosting provider. Please check back shortly.
1:37Property Binding – Bidirectional
Take topic challenge
An expression binding is one of the most powerful kinds of property bindings. It uses a simple expression language to calculate a value. For example, a Fahrenheit to Celsius conversion. This expression can involve lots of dynamic data such as other properties, Tag values, results of Python scripts, queries, and so on.
Video recorded using: Ignition 8.1
Transcript(open in window)
[00:00] In this lesson, I'll demonstrate one of the most powerful kinds of property bindings, the expression binding. In my Vision project. I have a window with an LED display that's currently bound to an OPC tag that's pulling in a temperature value. This tag is currently displaying the temperature in Fahrenheit, but I want to show the temperature in Celsius. I can accomplish this with an expression binding. I'll open the binding window and you can see that it's currently set up as a tag binding. Under the property category bindings on the left side of the window. I'll click expression. Expression bindings use the expression language to calculate and return a single value. Within the expression binding window I can use the helper buttons on the right to help build my expression. These two buttons can be used to insert references to properties or tags. And for example, I can click this button and select my temperature tag and a reference would automatically be inserted into the expression with the proper syntax. I can then use the rest of the buttons to massage or manipulate my values.
[01:04] This button with the plus and equal signs will show the different mathematical, logical, and bitwise operations that I can use. Finally this button at the bottom will list the expression functions that are available. I want to convert this tag value to Celsius so I can take the value that's returned from the tag reference and subtract 32 from it and then multiply that difference by 5/9 and this will convert the temperature from Fahrenheit to Celsius. I'll hit OK and you can see that the value will now change based on the calculations in the binding. I have another window in my project that takes the same idea one step further. I have an LED display and then these two radio buttons labeled Fahrenheit and Celsius. I'll open up the binding on my LED displays value to show the expression function I'm using. I have the syntax for this function commented out on the first line. If is the name of the function and then there's a set of parentheses after the name that shows it's a function and this function takes three parameters.
[02:04] First is the condition that it will check next is the value that will be returned if that condition is true and finally the value that will be returned if the condition is false. Below this, I've typed out the function, but added a new line after each parameter to make it more readable. So I'm checking the "Radio Button Fahrenheit" component's "Selected" property. If that property is true, I display the temperature in Fahrenheit. If that condition is false, then the value will be returned after being converted to Celsius. I'll close out of this window and quickly show you the bindings on the selected property of each radio button and you can see that they check the other radio button's "Selected" property and then negate that. In other words, if the other component is selected this one will not be selected and vice versa. When I put the designer into preview mode, you can see that selecting a radio button unselects the other and converts the temperature to the corresponding unit all with the help of expression bindings.