Property Nodes


Property Nodes

With property nodes, you can start making your program more powerful and a lot more fun. Property nodes allow you to programmatically control the properties of a front panel object: things such as color, visibility, position, numeric display format, and so on. The key word here is programmaticallythat is, changing the properties of a front panel object according to an algorithm in your diagram. For example, you could change the color of a dial to go through blue, green, and red as its numerical value increases. Or you could selectively present the user with different controls, each set of them appearing or disappearing according to what buttons were pressed. You could even animate your screen by having a custom control move around to symbolize some physical process.

To create a property node, pop up on either the front panel object or its terminal and select a property from the Create>>Property Node submenu. A terminal with the same name as the variable will appear on the diagram. To see what options you can set in a control's property node, click on the node with the Operating tool or pop up on the node and choose Property (see Figure 13.28). Now you have the choice of which property or properties you wish to select. Each object has a set of base properties (common to all types of controls), and usually, an additional set of properties specific to that type of control.

Figure 13.28. Some of the many properties available for controls and indicators


Just as with local variables, you can either read or write the property of an object (although a few properties are read-only). To change the mode of a property, pop up on it and select the Change to Write/Read option. The small arrow inside the property node's terminal tells you which mode it's in. A property node in write mode has the arrow on the left, indicating the data is flowing into the node, writing a new property. A property node in read mode has the arrow on the right, reading the current property and providing this data. The same analogy we used for locals, a control (read mode) and an indicator (write mode), holds for property nodes.

An interesting feature of property nodes is that you can use one terminal on the block diagrams for several properties (but always affecting the same control or indicator). To add an additional property, you can use the Positioning tool to resize the terminal and get the number of properties you need, much in the same way multiple inputs are added to functions like Bundle, Build Array, etc. Figure 13.29 shows two properties on the same terminal for the numeric control gain.

Figure 13.29. Property Node with Visible property in read mode and Numeric Text Colors in write mode


Note that the Visible property is in read mode and the NumText.Colors property is in write mode. You can configure each property from its pop-up menu by choosing Change To Write or Change To Read. You can change all properties on the node by choosing Change All To Write or Change All To Read.

Let's look at a simple example VI, PropertyNode Example.vi, which may be found on the CD-ROM in the EVERYONE\CH13 folder (see Figures 13.29 and 13.30). Suppose you wanted to have a front panel that would hide certain specialized controls except for those occasions when they were needed. In the following front panel, we see a tension gauge and a Boolean alarm switch (see Figure 13.29). We include a button that says show/hide advanced controls..., hinting at the possibility that if you pressed it, some really obscure and intricate options will pop up (see Figure 13.30).

Figure 13.30. PropertyNode Example.vi front panel with advanced controls hidden


In this example, we've included two more controls, gain and offset, which are made invisible by setting their property nodes' option "Visible" to false unless the button is pressed. If the show/hide advanced controls . . . button is pressed, then ta-da! . . . the two knobs become visible (see Figure 13.31).

Figure 13.31. PropertyNode Example.vi front panel with advanced controls visible


The entire block diagram would be encompassed in a While Loop like the one shown next to make the button control the visibility of the two knobs and thus give the "pop-up" effect (see Figure 13.32).

Figure 13.32. PropertyNode Example.vi block diagram


You will learn about the tab control in the section, "Cool GUI Stuff: Look What I Can Do!." Once you are familiar with it, come back to this example and see if you can save some front panel real estate by putting the "advanced" controls (gain and offset) into different pages of a tab control.


Often you will want to use more than one option in an object's property node. Remember, instead of creating another property node, you can select several options at a time by enlarging the terminal with the Positioning tool (much like you enlarge cluster and array terminals). You will see each new option appear in sequence; you can later change these if you like by clicking on any item with the Operating tool.

What do some of the base options in a property node refer to?

  • Visible: Sets or reads the visibility status of the object. Visible when TRUE; hidden when FALSE. Use the Visible property to hide controls (or indicators) from the user. Don't try to simply set the color of a control to transparenttransparent controls might appear to be invisible, but they are not hidden and the user may still (unknowingly) interact with them.

  • Disabled: Sets or reads the user access status of a control. A value of 0 enables the control so the user can access it; a value of 1 disables the control without any visible indication; and a value of 2 disables the control and "grays it out."

  • Key Focus: When true, the control is the currently selected key focus, which means that the cursor is active in this field. Key focus is generally changed by tabbing through fields. Useful for building a mouseless application. See Chapter 15 for more information on key focus.

  • Position: A cluster of two numbers that respectively define the top and left pixel position of the front panel object.

  • Bounds: A cluster of two numbers that respectively define the height and width in pixels of the entire front panel object.

  • Blinking: When true, the front panel object blinks.

  • Format and Precision: Sets or reads the format and precision properties for numeric controls and indicators. The input cluster contains two integers: one for format and one for precision. These are the same properties you can set from the pop-up menu of the numeric object.

  • Color: Depending on the type of object, you may have several color options. The input is one of those neat color boxes that sets the color of the text, background, etc., depending on the object.

  • Tip Strip: This is the text that appears when the user holds the mouse still over the control.

  • You'll also notice every object has properties called ClassID, ClassName, Owning VI, Owner. Don't worry about them at this point. They are for very advanced and relatively obscure LabVIEW programming scenarios.

The Help window really is helpful when using property nodes. If you move the cursor onto the terminal of a property node, the Help window will show you what the property means, and what kind of data it expects. Also, you can pop up on a property node and select Help to open the LabVIEW help file topic for the property that you popped up on, as shown in Figure 13.33.

Figure 13.33. Showing the LabVIEW help for a specific property from its pop-up menu


If you are unsure about the data type to wire to a property (in write mode), you can pop up on the property node terminal and choose Create Constant to create a constant of the correct data typethis is an especially handy time-saver when the input is a cluster.

Almost all controls or indicators have the base properties. Most of them have many more, especially tables and graphs (which can have over 100 properties!). We won't even begin to go into most of these properties, partly because you may never care about many of them and you can always look up the details in the manuals. The best way to learn about property nodes is to create some to go with your application and begin to play around with them. You'll find that property nodes are very handy for making your program more dynamic, flexible, and user-friendly (always good for impressing your non-technical manager).

Another Example

Graphs and charts have zillions of options in their property nodes, as you can see by popping up on the terminal of a chart's property node (see Figure 13.34).

Figure 13.34. The zillions of properties of charts and graphs


This next example, which can be found in the property node examples in the full version of LabVIEW, shows just one of the many aspects of a graph you can control programmatically (see Figure 13.35). Chart Property Node.vi lets you select one of three display types for the chart: Strip, Scope, and Sweep (if you need to, review Chapter 8, "LabVIEW's Exciting Visual Displays: Charts and Graphs," to see what they do).

Figure 13.35. Chart Property Node.vi front panel


You can select the chart mode and watch it change even while the VI is running. The way this is done is through the Update Mode option on a chart's property node (see Figure 13.36).

Figure 13.36. Chart Property Node.vi block diagram


Activity 13-4: Using Property Nodes with Charts

Write a VI that graphs three channels of data (either real-time data through a DAQ board, or random data). Let the user turn on or off any of the plots with three buttons. Because this is a chart and not a graph, the data will accumulate along with the old data, even if the VI is closed and re-opened. Add a "CLEAR" button that clears the chart (see Figure 13.37).

Figure 13.37. Front panel of the VI you will create during this activity


When using a multiplot graph or chart, you can only affect the properties of one plot at a time. The plots are numbered 0, 1, . . ., n for property node purposes. A specific property, called Active Plot, is used to select the plot for the properties you are modifying or reading. In this exercise, you will need to build some case statements like the ones shown in Figures 13.38 and 13.39.

Figure 13.38. Part of the block diagram you will create, which shows plot 0


Figure 13.39. Part of the block diagram you will create, which hides plot 0


The Boolean text of the checkbox (or any Boolean, for that matter) is clickable, meaning that when you click on the text, it is the same as clicking on the Booleanit will change states. When you place a checkbox (found on the System palette), it will appear with both its label and Boolean text visible. Hide the label (right-click the checkbox and unselect Label from the Visible Items submenu) and change the Boolean text to anything you wishin our case "Channel 1 Visible" (etc). Test whether clicking the Boolean text causes the checkbox to change values.


To clear a chart, use the History Data property of the chart. Then wire an empty array to this property node.


Save your VI as Property Nodes-Graph.vi.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net