Example Code

Queued Message Handler using Variants

Code and Documents

Attachment

Download All

Dear NI Community,

I was trying to pass different data around my producer consumer with events architecture and stumbled across the queued message handler template project.  I noticed how you could use the variant data type to pass string, boolean and numeric data types without having to use multiple queues.  I pass a cluster around containing a type defined enum and a variant.  The type def enum is the message and the variant is the data associated with that message.


I use a case structure in the consumer loop to cast the variant data back into it's original type.

Queued Message Handler using variants.png

Front Panel.png

Enjoy!


Rob

Robert Ward
Applications Engineer, NI

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

Comments
mtedaldi
Member
Member
on

Very useful!

If I had only looked here earlier since I've created almost exactly the same for a recent project.

--
Marco Tedaldi, University of Zurich, CLAD
MrJackHamilton
Member
Member
on

What also nice to add to your Queue cluster is the Error Cluster and a Timestamp.

Error Cluster:Allows you to pass errors to the other loops and create an in-line error flow. Now the GUI code can receive errors from other queue driven threads.

TimeStamp: The timestamp is useful for timing your queue events. In one case, I was able to detect a double-click from the Event Structure at the control loop; because I could look at the time between messages. It's also great for debug and event logging, as you have the event timing of messages.

anita.gade@yahoo.co.in
Member
Member
on

Like the project template given in LV for queued message handler, I want to develop an application which has about 15 fp controls ( which have been clustered in groups of 4, 5 and 6 and then all 3 clusters again clustered into 1 single cluster). I want to pass the reference of this into the QMH and unbundle and update them or process data accordingly like save data to file or read from file etc.

 

Could anyone please help me with this. Have been struggling working with the references.

 

Thanks heaps in advance for all the help rendered.

 

 

Contributors