From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advantages of Using Queued Message Handler vs. Standard State Machine

Hello,

 

What are the advantages of using a Queued Message Handler?  Also, why are they more powerful than using Standard State Machines?

 

Thanks!

0 Kudos
Message 1 of 7
(7,993 Views)

They are really just sort of an extension of a state machine.  The general idea is that you have one loop doing a specific job.  You then use a queue to tell it how/when to do this job.  For instance, I might have a log file loop.  I will send it commands to open a file, write some data, write some more data, and finally close the file.  Each of those commands are coming from the queue.  The beauty with this setup is that anybody that can get a reference to that queue can send the command to that loop.

 

So the QMH is "better" than a state machine mostly because of the decoupling of functions.  In a given application, I will have a loop for log file writing, GUI updates, reading of a DAQ, instrumenet communications, server communications, etc.  Trying to do all of that in a single loop state machine is a major pain in the rear end.  Seperating them out makes life so much easier.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 7
(7,985 Views)

Thanks CrossRulz - I am new to Queues and Queued Message Handlers.  Are there any basic examples out there that would give someone a good grasp on how a QMH works?

 

Thanks!

0 Kudos
Message 3 of 7
(7,979 Views)

Hello hobby1,

 

If you're using LabVIEW 2012 or newer, there is a QMH template that ships with it, and the documentation on how it works and how to modify it for your needs is fairly extensive. This documentation is included in the template project itself (under the Project Documentation virtual folder); instructions for locating it can be found here:

 

Queued Message Handler Template Documentation

http://www.ni.com/white-paper/14119/en/

 

Regards,

Tom L.
Message 4 of 7
(7,963 Views)

After a quick search, you might want to start here: Queued Message Handler using Variants

 

Once you get a good handle on queues, you could go into the QMH Sample Project.  Here's a presentation Darren did on the sample project and the decisions that went into the design:[NIWeek 2013] Queued Message Handler: Caveats and Design Decisions


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(7,961 Views)

One of the differences noted in the excellent links provided in the Reply from @crossrulz was that the QMH was designed for parallel loops, while the Simple State Machine was a single-loop design.  There are two other (much more advanced) designs that extend the Parallel Loop theme, but involve LabVIEW Classes (which have their own "Learning Curve" -- the Actor Framework and the Delacor Queued Message Handler (or "DQMH"), recognized as a 2016 "Product of the Year" Award from NI.

 

You are probably not ready for either of these at this time -- I'm mentioning them here to illustrate that LabVIEW and its tools can help you design and maintain Projects with many "movable, interacting parts".

 

Bob Schor

0 Kudos
Message 6 of 7
(3,031 Views)

@0utlaw wrote:

Hello hobby1,

 

If you're using LabVIEW 2012 or newer, there is a QMH template that ships with it, and the documentation on how it works and how to modify it for your needs is fairly extensive.

 

 


 

 

The QMH concept makes sense but that example program/template really makes no sense to me.

 

I have been coming back to that QMH Template over and over again since probably 2014 and still have not managed to modify it for any of my needs. Everything is so tightly coupled that it is impossible to make any changes without blowing the whole thing up.

 

In the end it has always been faster to just start from scratch than try to modify a program template. 

 

========================
=== Engineer Ambiguously ===
========================
Message 7 of 7
(3,010 Views)