Viewpoint Systems, Inc.
800 West Metro Park
Rochester, NY 14623
Phone: 585.475.9555
Fax: 585.475.9645
Viewpoint Data Management, LLC.
800 West Metro Park
Rochester, NY 14623
Phone: 585.475.9555
Fax: 585.475.9645
Viewpoint News, Winter 2008In the last issue, we presented some tips for enhancing mouse actions in LabVIEW via the Ctrl key. In this issue, we will follow along with the theme in the main article and provide a flexible way to pass data between the Consumer and Producer loops that will work for any application, thus making the Consumer \ Producer template produced by LabVIEW even more useful.
In the Producer \ Consumer framework template, the Producer loop passes data to the Consumer loop. (See the main article for details on this template.) As illustrated in the main article example, knowing the source of the data assists application development. In that example, a string “name” indicated the data source and the data was an array of doubles.
Download the demo VIs from this article:
Source Naming


Note how the block diagram above of a simple VI, which uses a state machine, grays out the enum constants while the enum is being edited. After editing, the new enum labels appear without needing to edit the diagram.
General Data Typing
Converting data into a variant is simple: use the To Variant tool under the Functions>>Communications>>DataSocket>>Variant or Advanced>>Data Manipulation>>Variant palettes. Note the basic tools are also under the Functions>>Communications>>ActiveX palette.

In the example above, the ‘To Variant’ VI converts the Waveform into a variant, and the ‘Variant To Data’ VI converts it back.
Queue Creation and Usage
To create a cluster (typedef, of course) with the appropriate enum and a variant and wire an instance of this typedef cluster into the queue.
To push an element into the queue, create the cluster by combining the enum and a variant created by passing your data into ‘To Variant’ and push the cluster into the queue. To retrieve the data, extract the element from the queue, unbundle, and use ‘Variant To Data’ to convert the variant to your original data. At this point, you will need to use the enum value to assist you in understanding which type of data the variant holds.