Our online shopping is experiencing intermittent service disruptions.

Support teams are actively working on the resolution.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two way communication between vi using queue

Hi all; I have two VIs here which I used Producer/Consumer loop template to communicate between them. Panel - Add.vi has an Add button which will add data into listbox in Panel - List2.vi by using queue. Panel - List2.vi has one delete button which will delete the data in listbox when the user press it. In the same time it will send the update data to the Panel - Add.vi through queue communication. This program works well, but because both VIs have queue and dequeue function, when I press Add button for the second time, the listbox did not update the data because the Panel - Add.vi has dequeued the data into its consumer loop (in Unsolved.zip folder). So, in order to tackle this problem, I have created one case structure for "Add" so that it will enqueue again the data to send it to the Panel - List2.vi (Solved.zip folder). My question is, is there another way for efficient communication between these two VIs by using queue and dequeue operation?
Download All
0 Kudos
Message 1 of 9
(4,307 Views)

Hi DUE,

you can use two queues, one for each direction.

Mike

Message 2 of 9
(4,305 Views)
The queue is very effective in a many to one setup. It is not very usable in a many to many setup as yours is. To handle many to many (2 or more way traffic) you will have to create a queue for each direction of data.
Regards,
André (CLA, CLED)
0 Kudos
Message 3 of 9
(4,303 Views)
I agree with both Mike and Andre'.  You will need two Queues.
 
Just be careful not to create a deadlock condition where both loops are waiting for the other to send something up the Queue to continue.. 😉
 
RayR
0 Kudos
Message 4 of 9
(4,285 Views)
The queue subject is new to me. I'm really sorry that I could not understand your explanation. Could you give detail explanation about this? Thanks
0 Kudos
Message 5 of 9
(4,272 Views)

Hi DUE,

see the attached vi´s please. I changed your code, so that you can communicate in both directions.
Hope it helps.

Mike

Download All
0 Kudos
Message 6 of 9
(4,265 Views)

See attached example.  It is oversimplified, but should give you an idea how queue works.

The bottom loop will send a message to the top loop if the message is blank or not.  The reason the msg dissappears is because of the 250 ms timeout, which clears the message..  It is to show you that if you use a timeout, you have to handle the info received quickly enough.. 😉

RayR

 

0 Kudos
Message 7 of 9
(4,264 Views)
Thank you very much to both of you MikeS81 and JoeLabView. It's really help me a lot
0 Kudos
Message 8 of 9
(4,232 Views)
Glad to help.
 
Hope you saw how the loops function when the Queues have a timeout setting.  It is possible to use logic rather than timeout to make sure you avoid deadlocks. 
 
Have fun!
 
RayR
0 Kudos
Message 9 of 9
(4,226 Views)