From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Queued Message Handler SubVI causing issues

Solved!
Go to solution

LabVIEW community, 

 

I've been trying to learn how to use the Queued Message Handler architecture over the last couple of months but I'm running into an issue that is causing me grief.  I've gone through the template that ships with LabVIEW and I've also tried to create my own "custom messaging VIs" from scratch in an attempt to know exactly what I'm using rather than just use the template blindly.  However, I must be missing something.

 

In the attached .zip file, the QMH Test MAIN VI gets hung up if the message queues cluster is wired to the "test loop subVI".  If I delete the wire, then my Queue1 will work and I can execute Test1 and Test2 and the values update in Loop1.  But since the test loop subVI isn't wired properly I can't terminate the VI properly without using the abort button. 

 

I'm trying to mimic a VI that I'm currently working on with this simple VI. Is there an issue with have a Dequeue function inside my test loop subVI? I basically just want the test loop subVI to go from "Init" to "Idle", send an "Idle" message to Loop1 and then just sit there until the exit command is pressed.  I seem to be having an issue with the Dequeuing even though there is only one dequeue function per queue.

 

Any help would be greatly appreciated.  I am in a pinch to get my real VI working but need to overcome this issue first. The VIs were created with LV2017.

 

Cheers, 

-MB

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 1 of 9
(3,305 Views)

Can you save for 2016 or earlier?

0 Kudos
Message 2 of 9
(3,289 Views)

My apologies.  I should have done this in the first place.  However, I'm not sure if I did it properly.  I tried to save for previous version and chose 2012 (as this is the version I was using before moving to 2017) but there was a warning.

 

Please let me know if there are any issues and I can tried to save and upload again. 

 

Thanks, 

MB

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 3 of 9
(3,284 Views)
Solution
Accepted by topic author Brown@KTR

Your dequeue VI wrapper can only run at one place at a time because it's not reentrant.  Either make it reentrant or switch to using the primitive instead of the wrapper with the built-in un-bundler.

Message 4 of 9
(3,269 Views)

As Kyle mentioned, you have locked up your VI because two functions are trying to call Dequeue Message at the same time. Unfortunately, the first one has nothing to dequeue because you've set it up so that your "QHM Test Loop" will enqueue data. Although setting Dequeue Message fixes your immediate problem, you are setting yourself up for a hard time debugging by having the loops send data back and forth to each other. A much easier approach is to have almost all of the data going "one-way" with a single "smart loop" that knows what's going on. There will be times when you need to get the data out of the loop, and I would suggest taking a look at how DQMH does it, by setting up a temporary notifier.

Message 5 of 9
(3,264 Views)

This makes a ton of sense...I only checked the enqueue wrapper for re-entrant behaviour in the template VI and foolishly assumed that the dequeue wrapper was the same. 

 

Thank you very much. Makes me wish I came to the forums earlier.

 

Cheers, 

MB

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 6 of 9
(3,255 Views)

Brown@KTR wrote:

This makes a ton of sense...I only checked the enqueue wrapper for re-entrant behaviour in the template VI and foolishly assumed that the dequeue wrapper was the same. 

 

Thank you very much. Makes me wish I came to the forums earlier.

 

Cheers, 

MB


It's good to try it out yourself before coming here, though.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 9
(3,249 Views)

Gregoryj, 

 

Thank you for the suggestion.  I created this test VI so that I could upload it to the forum.  In my real VI, I have an Event Handling loop, a control loop, a logging loop and a display loop.  The Control loop is close to your "smart loop" suggestion.  All of the messages from the event handling loop are dequeued there and then sent to the other loops.  The only things I send back to the control loop are errors.  

 

I haven't looked into the DQMH yet but I will certainly do so.

 

Cheers, 

MB

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 8 of 9
(3,246 Views)

Bill, 

 

I totally agree.  However, it would have been nice to sleep for more than 3 hours last night. 

 

Thanks again NI community.

 

Best regards,
Brown

The more I know...the more I don't know
Message 9 of 9
(3,242 Views)