LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wrap queue into class, but it doesn't work properly.

Dear everyone,

I wrapped queue into a queue class, the class data is a queue array. I use this class to create a queue array, so I can use queues to comunicate with several while loop. 

but accessing more than 1 queue, it doesn't work properly.

 

detial is as belows. only disable the second queue loop. this vi can work. 

Can someone please help me?

the source code(ver8.6) is attached too.

thank you in advance.

 

Queue Group.png

0 Kudos
Message 1 of 2
(3,075 Views)

Your problem is that Dequeue By Index is not reentrant, so only one copy of it executes at a time. You don't know which copy will execute first. Let's say the one that is listening for index 0 executes first. It sits there and waits until a message is received. Meanwhile, because it is executing, the copy listening to index 1 cannot run. You can enqueue messages in queue 1, but they won't be dequeued until the copy listening on queue 1 runs, and that can't happen until the instance listening to queue 0 completes (when it receives a message).

 

Make Dequeue By Index reentrant and it should work as you expect. You set this in VI properties under the Execution category.

 

Also, you should move the OK and Exit buttons inside the corresponding event cases so that the latching works properly.

Message 2 of 2
(3,060 Views)