LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 loops block program due to queue problem

Solved!
Go to solution

Hi,

I wrote a program that controls many instruments in a setup.

Two of the functionalities of the program are: view image from camera and save video from camera stream.

Since these operations happen in parallel to other user inputs, I put them in 2 while loops with a queue to operate them. I also wired a boolean reference so I can stop them from outside the VI.

When I press the general STOP button the loops stop running but the program sometimes gets stuck inside the video loop. When I “highlight execution” nothings shows but I see that the number of iterations can only be shown by probe #4 and not #3 ( see in attached image). Of course the program never reaches the next frame (#3) and the program just hangs forever or until I press the Abort execution.

It seems to me like a Labview bug but “recompiling all” didn’t help. Can someone have an idea why does this happen? Is it related to the queue read by both loops?

 

BTW this problem happens even if i never started recordeing video or viewing the image.

 

thanks 

Amos

0 Kudos
Message 1 of 4
(2,822 Views)

Hello amose,

when your have one element in your queue both loops enter their "False" state. The element is then dequeued in one of the loops, which in turn forces the other loop to wait for a new element. You should try to avoid using more than one dequeue on the same queue (A queue can have multiple enqueues though).

 

From what I can see using two seperate queues for your image and video functionalities might be more suited to what you want to achieve.

Kind regards

0 Kudos
Message 2 of 4
(2,804 Views)
Solution
Accepted by topic author amose

A queue should only ever have 1 place that dequeues.  So I agree that you should use two different queues for this effort.

 

Additionally, do not use the Get Queue Status to check to see if data is available.  Just let the Dequeue do the waiting.  If you need to check other things in the loop, use the timeout.  This simplifies your code quite a bit.


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 3 of 4
(2,763 Views)

Thanks,

I used many times the dequeue without paying attention to the timeout input.

this is the timeout that was not wired and hanged my execution when the queue was already emptied by the other loop.

0 Kudos
Message 4 of 4
(2,740 Views)