Invoke Nodes

Invoke nodes are very similar to property nodes. Calling an invoke node runs a single method on the front panel object and sometimes requires inputs, (also known as "arguments"). In a way, calling an invoke node is similar to calling a subVI or calling a function or method in other languages.

The difference between a property node and an invoke node is that calling an invoke node, "executes something"it doesn't just change the value of a property. You can think of invoke nodes as functions that you execute; whereas a property node is a property, or state, that can be read from or written to.

To create an invoke node, pop up on either the front panel object or its terminal, and select one of the control's methods from the Create>>Invoke node>> short-cut menu. A terminal with the same name as the variable will appear on the diagram. The method name will appear as the first item in the invoke node, and all the arguments will appear as items beneath the method name. You can change the method being called by the invoke node with the Operating tool or pop up on the node and choose Methods>>. Now you have the choice of which method you wish to select. Each object has a set of base methods, and usually, an additional set of methods specific to that object. One base method that is available for all controls is Reinitialize to Default (see Figure 13.40). It doesn't have any arguments, and calling it will do just what it saysreinitialize the control to its default value.

Figure 13.40. Configuring a control's invoke node to call the Reinitialize to Default method

Activity 13-5: Using Invoke Nodes to Export an Image from a Graph

In this activity, you'll see how to use an invoke node specific to graphs, which allows you to export the graph to an image file.

We'll use the VI you created in Chapter 8, Graph Sine, so you should open that (or use the one on CD-ROM, in the EVERYONE\CH08 folder).


Open Graph Sine


From the block diagram, right-click on Waveform Graph and select Create>>Invoke Node>> ExportImage. You should see an invoke node like the one in Figure 13.41.

Figure 13.41. Invoke node configured to call the Waveform Graph's Export Image method


The Export Image method creates an image of the graph it's associated with, and sends this image to the clipboard or to a file. The following inputs are required:

  1. FileType can be BMP, EPS, EMF, or PICT.

  2. Target can be Clipboard or File.

The following inputs are optional:

  1. Path is the path to the file to be saved.

  2. HideGrid is a Boolean, which if TRUE, hides the graph's grid on the image.

  3. AlwaysOverwrite is a Boolean, which if TRUE, overwrites the image file even if one with the same path and filename exists.


To use this node, you can pop up on each of its inputs and select the appropriate value. Set FileType to "BMP" and Target to "File."


For the path, it will be best if we allow the user to choose the path with a dialog. Here's an easy way to program a prompt for the user to enter a filename: Use the Express VI File Dialog (shown in Figure 13.42), which may be found on the Express>>Input palette.

Figure 13.42. File Dialog express VI

When you drop the File Dialog Express VI onto the block diagram, you will be asked to configure some options for this dialog. Select "Files only" and "New or existing."


Finally, use a sequence structure to make sure that things happen in the right order, and wire the output of File Dialog to the "path" input in ExportImage.

Your VI's block diagram should look like Figure 13.43.

Figure 13.43. Block diagram of the VI you will create during this activity


Save your VI as Invoke Node in the MYWORK directory.

When you run it, you should be able to choose a filename to save the bitmap under. Open the bitmap file this VI creates and you'll see an image created from the waveform graph.

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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: