LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel While Loops with QMH

Solved!
Go to solution

Hi,

 

I am running a RT program which uses the Queued Message Handler Architecture, where the QMH receives messages, via a network stream, from an HMI.

On the RT program I would like it to execute different programs based on changing the controller mode on the HMI. Each program usually has a few startup items, which must be executed and it also has a few tasks to execute, when the task has been completed. In between these tasks is a WHILE loop which runs the program.  

 

To investigate the architecture required on the RT, to start and stop different programs, I created a heavily simplified VI to test the architecture which I have attached. Please note that the QMH is not properly setup here, but has been included to show the problem that I am battling with. If I remove the queue the code executes without issue...

 

Say the user on the HMI selects DAQ mode, the state change is received by the QMH which then updates the states and requests that the current program running must stop and execute its shutdown tasks. Thereafter, the program ready flag goes high, which then allows the next program to run. 

 

However, I find that the QMH While Loop gets stuck while the program's WHILE loop runs, preventing the program from stopping and running the next requested program.

 

Any ideas on how to fix this would be greatly appreciated.

As mentioned above, the program runs fine when the queue is omitted.

 

 

0 Kudos
Message 1 of 3
(104 Views)
Solution
Accepted by topic author dmac777

I've done something similar, but different.  I've had a Main (or Host) controlling multiple Stations (or RT Programs) where the RT routines were designed to run simultaneously and concurrently.  

 

In your case, you want two RT routines RT-A and RT-B, to run separately and independently (possibly B, then A, say).  If I were doing this, I'd write a QMH-based routine to do Task A and an RT counterpart (RT-A), and a separate routine for Main B and RT-B.  You would need Network Streams for Host->RT commands, RT->Host data, and possibly RT->Host Status.

 

Once both work, combine them.  Main will get a few "Extra" states to decide whether the User wants to do A or B, will send that information to the RT side which is now preparted to run either Init A, Start A, Do A, Finish A, Exit A or a similar set of B States.  There will probably be additional States (so allow you do Do A, Do B, Do A, Quit.

 

This "model" combines the two State Machines into one with the set of States for both A and B, making it a lsrger program (but unless you are using a myRIO, you've probably got scads of available program memory).  

 

Does this make sense to you?\\

 

Bob Schor

0 Kudos
Message 2 of 3
(68 Views)

Bob, thanks for your prompt response.

 

I understand what you are saying. Essentially create two independent HMI Main & RT Main programs for each RT program (A,B,C etc) with their own queues and network streams. 

Then consolidate the two HMI Mains & RT Mains into a single HMI Main and RT Main. 

 

Space as you mentioned, isn't an issue. 

 

I will go this a go. Thanks 

0 Kudos
Message 3 of 3
(37 Views)