Example Code

Generic Queue Sub-VI Via A Polymorphic VI using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This VI demonstrates how to provide a double and a string instance of the Queue Sub VI and use them in your program.

 
Description
LabVIEW users may want to create a generic sub-VI which can perform operations on Queues of different data types.  However, once a control is made for a Queue VI's Queue input, the control is set to a specific data type.  The instance of the polymorphic Queue VIs which ship with LabVIEW is only updated when the VI is wired directly.  As such, if a user wires the connector pane of his/her VI to this control and wires a Queue of a different data type to it, a broken wire is displayed on the top level VI.

In order to get around this, the user should create one VI which accomplishes the task and copy this VI, changing the name and data type of each copy, as many times as there are data types needing to be used.  Once these files exist, place them in a Polymorphic VI and use this throughout your program.

The attached project has a double (DBL) and a string instance of the Queue Sub-VI.  These sub-VIs are included in the "Queue Sub-VIs" Virtual Folder.

 

Requirements

  1. LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Since all sub-VIs perform the same operation, create a single VI (to be used as a sub-VI) that does the task which you want to complete for a single Queue data type.
  2. Copy this VI and rename each instance to the appropriate data type.
  3. Edit each of these new sub-VIs to work with the appropriate (based on its name) Queue data type.
  4. Create a new polymorphic VI. (File>>New, VI>>Polymorphic VI)

 

Additional Information or References

VI Snippet

queue 2012 NIVerified.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.