12-05-2014 02:58 AM
Hello, I have to use, for the first time a queued message handler. I'd like to know what is the best way to share data between cases in a loop and from a loop to another, I think with local variables isn't the best way...
However all the tips on the queued message handler are welcome!!!
Thanks
12-05-2014 04:15 AM
As "Queued Message Handler" is a name used for slightly different implementations, can you please provide a small example of your code?
Depending on the "sharing" of data, you can internally use a shift register for one QMH.
Distribution of data to other QMHs, you would use the queue of the target QMH. The target QMH has to inlcude a case storing that data in e.g. a shift register.
Norbert
12-05-2014 07:09 AM
@smilegv wrote:
I'd like to know what is the best way to share data between cases in a loop
Shift registers. Doesn't matter if QMH, State Machine, Producer-Consumer, etc.
@smilegv wrote:
I'd like to know what is the best way to share data ...from a loop to another
Well, now that completely depends on what you are passing around. Streaming data? Use a Queue or User Event. Last known value (ie Tag)? Global Variables, Action Engine.
12-06-2014 09:45 PM
In "recent LabVIEW Versions" (LabVIEW 2012 and more recent, possibly earlier as well), you can open a new Project, choose "From Template", and choose Queued Message Handler. It will create an NI-Standard Queued Message Handler with comments, documentation, and suggestions on how to modify it for your own needs. It includes passing data between States on shift registers, and passing data betwen loops (the QMH and an Event Loop) using Queues. By studying this, making some modifcations and "trying it out", you should be able to figure out a lot about this Design Pattern.
Bob Schor
12-07-2014 01:55 AM
Also have a look at the JKI "Statemachine" template (which is actually a type of queued mesage/event handler). Uses shift registers.
12-07-2014 07:16 AM