LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

queued message handler

Whether each case in message handler loop (MHL) executes parallely?

0 Kudos
Message 1 of 9
(4,034 Views)

Hi rakesh,

 

THINK DATAFLOW: cases in a case structure NEVER execute in parallel…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,032 Views)

the message hadling loop and event handling loop will execute parallely.. right?

Also whether  I have to add more  message handling loops, to execute more functions parallely?

0 Kudos
Message 3 of 9
(4,007 Views)

normally yes, unless you mess it up explicitly

tmp1.png


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 4 of 9
(4,002 Views)

rakesh@labview wrote:

the message hadling loop and event handling loop will execute parallely.. right?

Also whether  I have to add more  message handling loops, to execute more functions parallely?


To quote GerdW: THINK DATA FLOW!

 

If there is no data dependency between loops (ie Loop A does not have an output wire going to Loop B), they will run in parallel.  This is the whole point of having a QMH and Producer/Consumer.



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 9
(3,992 Views)

You can certainly have multiple Message-Handling Loops in one VI, but they each should probably be handling different Messages.  Notice the "probably" -- a counter-example is when the Message being handled has significant "block/idle" time (like I/O to a slow device) and you want, say, a few processes working on a single Queue, in parallel, to optimize throughput (we actually did this once, but a much better solution that was adopted was to design a better "saving" algorithm).

 

Bob Schor

Message 6 of 9
(3,983 Views)

I have to design a system with followiing requirements

I have to run several tests parallely.

Each test VI will generate some data. (Test VI)

That data has to be logged (Raw data log VI), parallely some processing have to be done on that data and to generate pass/fail status (processor VI). Processed data also have to be logged (Test data Logger). This all VI has to run parallely. 

I have attached my source code using QMH template. Whether this is correct way of implementation?. Whether each VI has to use separete queues. Please help

the Realtime_Data folder contains my main VI. GUI.VI

 

RandomData_Generation.vi

process.Vi

Saving_to_Textfile.vi

Save_to_textfile_with_status.vi

0 Kudos
Message 7 of 9
(3,934 Views)
0 Kudos
Message 8 of 9
(3,933 Views)

The Message Handler is the "Conductor" that "handles messages" (sequentially, not in parallel!) that come from other (possibly parallel) Proceses (or, indeed, from itself).

 

When designing with the QMH as (one of) your Design Pattern, it is helpful to make a list of the Messages it receives, and what it should do in response to these messages.  Since it handles Messages serially, you want it to not spend a lot of time processing any single Message, but handing off the task to other routines, as appropriate (i.e. being a Producef for a Producer/Consumer Design).

 

Here are some typical Messages:

  • Initialize.  Usually the first Message, sets up everything else.
  • Start Test X.  If you are running parallel routines using Start Asynchronous Calls, this can be where you "spawn" them.  If they are already running and waiting for a "Go" signal, this can be where you send the signal.
  • Process Data.  This is an example of a "Pass-through" Message.  One of your Parallel Processes needs to have some data Processed, but also needs the QMH to know about it and possibly "manage" the processing.  It would send the Data as the "Data" part of the Message, and the QMH would enqueue the data and send it to the relevant Consumer to process.
  • Shutdown.  Depending on how your Parallel Processes are structured, this can either tell them to Quit or be called when they tell you they've exited, so you can handle the orderly shutdown of the other loops in the Main Routine.
  • Error.  Come here if an Error appears in the QMH and figure out how to handle it.
  • Exit.  I like this to be my last State, the place where the QMH stops itself.

Once you have the Design, start coding it.  It should not look exactly like the Template that NI provides ...

 

Bob Schor

 

Message 9 of 9
(3,914 Views)