Activity 12. Use Property Nodes and Invoke Nodes

Your objective is to create a VI that programmatically modifies the appearance of a Tank indicator using a property node and programmatically changes the VI icon using an invoke node.

Front Panel

  1. Open a new front panel by selecting File»New VI, pressing <Ctrl-n>, or pressing the New VI button on the LabVIEW dialog box. Macintosh Press <Command-n>.
  2. Add a Tank indicator to the front panel.
    1. Select a Tank indicator located on the Controls»Numeric palette and place it on the front panel. Leave the default label.
    2. Double-click the topmost scale marker and change the value to 100.
    3. Right-click the tank and select Visible Items»Digital Display to show the digital display.
  3. Select a digital control located on from the Controls»Numeric palette and place it to the left of the Tank indicator. Label it Limit Setting. Set the value to 50.
  4. (Optional) Define the current values of the controls as the default values by right-clicking each control and selecting Data Operations»Make Current Value Default from the shortcut menu.
  5. Select two Path Controls located on the Controls»String & Path palette and place each below the Limit Setting control. Label the first Normal Image and the second High Image.
  6. Enter paths to the image files for each path control.
    1. Click the browse button next to the Normal Image path control. In the standard file dialog that appears, navigate to \labview\activity\solution\low_icon.bmp and click the OK button.
    2. For the High Image control, navigate to \labview\activity\solution\high_icon.bmp and click the OK button.
  7. Arrange the objects on the front panel. Your VI should appear similar to following illustration.

Block Diagram

  1. Open the block diagram by selecting Window»Show Diagram, clicking the block diagram window, or pressing <Ctrl-e>. Macintosh Press <Command-e>.
  2. Add a While Loop.
    1. Select a While Loop from the Functions»Structures palette and drag it to a corner of the block diagram window. Do not release the mouse button.
    2. While holding the mouse button, drag out an area that fills most of the block diagram window. When the area is large enough to encompass all the terminals, release the mouse button. LabVIEW draws a While Loop.
  3. Move the stop terminal next to the continuation terminal of the While Loop and wire them together.
  4. Add a Random Number (0-1) function located on the Functions»Numeric palette to the upper left of the While Loop.
  5. Add a Multiply function located on the Functions»Numeric palette, and wire one of its inputs to the Random Number (0-1) function. Right-click the other input terminal and select Create»Constant from the shortcut menu. Type 100 for the value of the constant and click the Enter button on the toolbar.
  6. Use the Wiring tool to wire the output of the Multiply function to the Tank terminal.
  7. Select a Greater or Equal? function located on the Functions»Comparison palette and place it near the wire that connects the Multiply function and the Tank terminal. Use the Wiring tool to connect the input of the Greater or Equal? function to the wire between the Multiply function and the Tank terminal.
  8. Add a Case structure next to the output of the Greater or Equal? function.
    1. Select a Case structure from the Functions»Structures palette and drag it next to the Greater or Equal? function. Do not release the mouse button.
    2. While holding the mouse button, drag out an rectangle suitable in size for three or four functions and their wire connections. Release the mouse button. LabVIEW draws a Case structure.
  9. Use the Wiring tool to wire the output of the Greater or Equal? function to the selector terminal of the Case structure. This causes the Case structure to select a case depending on the result of the Greater or Equal? function.
  10. Create a color box constant in each case of the Case structure.
    1. Select a color box constant from the Functions»Numeric»Additional Numeric Constants palette and place it in the Case structure.
    2. Click the color box constant. Select a blue color from the color picker that appears. You also can use the Coloring tool to right-click the constant to change the color.
    3. Click the increment button at the top of the Case structure to switch cases. Add another color box constant to this case. Place it in the same place as you placed the constant in the other case.
    4. Change the color of this constant to red as you did in step 10b.
  11. Create a Property Node for the Tank terminal.
    1. Right-click the Tank terminal and select Create»Property Node from the shortcut menu. A Tank Property Node appears next to the terminal.
    2. Right-click the Property Node and select Properties»Fill Color from the shortcut menu.
    3. Because this Property Node will change the fill color of the Tank, rather than read its color, right-click the Property Node and select Change to Write from the shortcut menu.
    4. Move the Tank Property Node to the right of the Case structure.
  12. Move the Normal Image terminal into the case that has the blue color box constant.
  13. Move the High Image terminal into the case that has the red color box constant.
  14. Add an Invoke Node.
    1. Select an Invoke Node from the Functions»Application Control palette. Place it to the right of the Case structure and across from the High Image terminal.
    2. Right-click the Invoke Node and select Select VI Server Class»VI from the shortcut menu.
    3. Right-click the Invoke Node and select Methods»Set VI Icon from the shortcut menu.
  15. Wire each color box constant to the Fill Color terminal of the Tank property node.
  16. Wire each image terminal to the Image File terminal of the Invoke Node.
  17. Add timing to the VI.
    1. Select the Wait Until Next ms Multiple function from the Functions»Time & Dialog palette and place it in an open area of the While Loop.
    2. Use the Wiring tool to right-click the input terminal of the Wait Until Next ms Multiple function and select Create»Constant. Enter 1000. This causes the While Loop to wait 1 second (1000 milliseconds) between iterations.
  18. Use the Positioning tool to arrange the objects on the block diagram. Your block diagram should look similar to the following illustration.

Running the VI

  1. Click the Run button to run the VI. The VI compares the level of the tank to the Limit Setting control. If the tank value is greater than or equal to the Limit Setting value, LabVIEW turns the tank color to red. If the data falls below the limit, the tank turns blue.

    Notice the VI icon also changes when the level of the tank exceeds the Limit Setting value. The icon changes to the dimmed lightbulb when level of the tank is below the Limit Setting value and to the lit lightbulb when the level is greater than or equal to the Limit Setting value.

  2. Click the stop button to stop the VI.
  3. Save the VI as Tank Limit.vi in the labview\activity directory.

Optional Steps

  1. Prevent the user from changing the image files that are used for the VI icon.
  2. Experiment with modifying other properties of the Tank indicator.
  3. Experiment with modifying other methods of the Invoke Node.

End of Activity 12. Use Property Nodes and Invoke Nodes