Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Creating a Member VI in a LabVIEW Class

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Create a member VI to access and perform operations on private data of the LabVIEW class. You can create a member VI in several ways.

Creating a Member VI from a Blank VI

Complete the following steps to create a member VI from a blank VI.

  1. Create a new LabVIEW class or open an existing class by selecting File»Open and navigating to the class you want to open.
Note  If you open the class using File»Open, the class opens in a class window instead of the Project Explorer window. You can develop the class in the class window just like you do in the Project Explorer window.
  1. In the Project Explorer window, right-click the icon for the class in which you want to create a member VI and select New»VI from the shortcut menu.

    A new member VI appears in the Project Explorer window and LabVIEW opens the VI.
  2. You now can develop the member VI to access and interact with the private data of the class.

Creating a Member VI from the Dynamic Dispatch Template

You can use any VI template to create a new member VI using the New dialog box, however LabVIEW provides a quick shortcut to creating a dynamic dispatch member VI that includes several features that many dynamic methods need. LabVIEW populates the new member VI with error in and error out clusters, a Case structure for error handling, the input LabVIEW class, and the output LabVIEW class. LabVIEW sets both the input and output terminals as dynamic on the connector pane of the VI. Complete the following steps to create a member VI from a dynamic dispatch template.

  1. Create a new LabVIEW class or open an existing class by selecting File»Open and navigating to the class you want to open.
Note  If you open the class using File»Open, the class opens in a class window instead of the Project Explorer window. You can develop the class in the class window just like you do in the Project Explorer window.
  1. In the Project Explorer window, right-click the icon for the class in which you want to create a member VI and select New»VI from Dynamic Dispatch Template from the shortcut menu.

    A new VI appears in the Project Explorer window and LabVIEW opens the VI automatically. The front panel of the VI displays a LabVIEW class indicator, a LabVIEW class control, and error in and error out clusters.
  2. Press the <Ctrl-E> keys to display the block diagram. The block diagram displays two LabVIEW class terminals, error in and error out cluster terminals, and a Case structure for error handling.
  3. You now can develop the member VI to access and interact with the private data of the class.

Creating a Member VI from the Static Dispatch Template

LabVIEW also provides a quick shortcut to creating a static dispatch member VI that includes several features that many dynamic methods need. LabVIEW populates the new member VI with error in and error out clusters, a Case structure for error handling, the input LabVIEW class, and the output LabVIEW class. Contrary to creating a dynamic dispatch VI, LabVIEW does not set the input and output terminals as dynamic on the connector pane of the static dispatch VI. Complete the following steps to create a member VI from a static dispatch template.

  1. Create a new LabVIEW class or open an existing class by selecting File»Open and navigating to the class you want to open.
Note  If you open the class using File»Open, the class opens in a class window instead of the Project Explorer window. You can develop the class in the class window just like you do in the Project Explorer window.
  1. In the Project Explorer window, right-click the icon for the class in which you want to create a member VI and select New»VI from Static Dispatch Template from the shortcut menu.

    A new VI appears in the Project Explorer window and LabVIEW opens the VI automatically. The front panel of the VI displays a LabVIEW class indicator, a LabVIEW class control, and error in and error out clusters.
  2. Press the <Ctrl-E> keys to display the block diagram. The block diagram displays two LabVIEW class terminals, error in and error out cluster terminals, and a Case structure for error handling.
  3. You now can develop the member VI to access and interact with the private data of the class.

Creating Member VIs for Accessing Data Members

You can quickly create a read or write accessor VI that is a member of the LabVIEW class. The read accessor VI unbundles LabVIEW class data so you can access the data in a calling VI. The write accessor VI rebundles new values for class data that you pass from the calling VI. You might use an accessor VI to read from or write to class data in VIs that are not members of the LabVIEW class. Complete the following steps to create a VI to access data of the class.

  1. Create a new LabVIEW class or open an existing class by selecting File»Open and navigating to the class you want to open.
Note  If you open the class using File»Open, the class opens in a class window instead of the Project Explorer window. You can develop the class in the class window just like you do in the Project Explorer window.
  1. In the Project Explorer window, right-click the icon for the class in which you want to create a member VI and select New»VI for Data Member Access from the shortcut menu. You also can right-click a data member in the private data control of the LabVIEW class and select Create Accessor from the shortcut menu.

    The Create Accessor dialog box appears.
Note  You must save a new LabVIEW class before using this option. LabVIEW dims the VI for Data Member Access and Create Accessor options if you have not saved the new class.
  1. Select the data member you want to access, the type of access, and if the new VI is dynamic or static. If you press the <Ctrl> key and select more than one data member, LabVIEW creates an accessor VI for each data member. If you select Read and Write in the dialog box, LabVIEW creates an accessor VI that provides read access and another accessor VI that provides write access.
  2. Click the Create button to create the accessor VI or VIs.

    A new VI appears in the Project Explorer window for each data member and each type of access you select, and LabVIEW opens each VI automatically. The names of the VIs consist of the access type you chose and the name of the data member, for example, Read Numeric.vi. The front panel of the VI displays a LabVIEW class indicator, a LabVIEW class control, the data member you chose, and error in and error out clusters.
  3. Press the <Ctrl-E> keys to display the block diagram. The block diagram displays two LabVIEW class terminals, the data member you chose, error in and error out cluster terminals, and a Case structure for error handling.
  4. You now can manipulate the class data from calling VIs.

Creating a Member VI to Override an Ancestor Member VI

You can create a dynamic dispatch member VI that overrides, or extends, the functionality of an ancestor dynamic dispatch member VI. A member VI can override a member VI from a ancestor class only if the following settings are the same for both VIs:

LabVIEW creates an override member VI that meets all of the requirements of a legal override if you select New»VI for Override from the shortcut menu. Complete the following steps to create an override member VI using the New»VI for Override option.

  1. Create a new LabVIEW class or open an existing class by selecting File»Open and navigating to the class you want to open. If you are creating a new class, you must save the class before you can create an override member VI for it.
Note  If you open the class using File»Open, the class opens in a class window instead of the Project Explorer window. You can develop the class in the class window just like you do in the Project Explorer window.
  1. In the Project Explorer window, right-click the icon for the class in which you want to create a member VI and select New»VI for Override from the shortcut menu.
Note  LabVIEW dims the VI for Override option if the class you select does not inherit member VIs that are available for you to override. The VIs in the ancestor class must be dynamic dispatch member VIs in order for you to override them.
  1. The New Override dialog box appears. The dialog box displays dynamic methods that ancestor classes define. Select the member VI you want to override.
  2. Click the OK button.
  3. A new VI appears in the Project Explorer window and LabVIEW opens the VI automatically. LabVIEW uses the ancestor VI icon and overlays the icon mask of the child class to create the icon of the new VI. Additionally, the front panel of the VI displays the controls and indicators copied from the ancestor VI, LabVIEW class indicators, and error in and error out clusters.
  4. Press the <Ctrl-E> keys to display the block diagram. The block diagram displays terminals that LabVIEW copied from the ancestor member VI. LabVIEW also wires the terminals to a Call Parent Method Node automatically.

You now can change the code on the block diagram of the override member VI as you need.

Note  A newly created override member VI initially behaves exactly as the ancestor implementation of the member VI. You can use an override member VI to add or subtract functionality from a parent implementation of a member VI.

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit