LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use queues for buffering

Solved!
Go to solution

Hello,

 

In my application, I am scanning all the com ports of my computer, checking for information on the buffer. What I want to do is run a comsumer/producer achetiecture so that I can constantly scan the com ports, and as soon as I recieve data on the buffer, it is sent out to a queue. That queue then runs another loop that does some database manipulation, and while it does that manipulation, I wanna go back and keep scanning the comports for more data.  My problem is that I want to be able to start and stop the program at any time, but I do not want to lose any information on the queue buffer. The database manipulation takes roughly 800 ms and the scanning of the com ports takes roughly 50 ms.

 

Basically, I want the program to stop when I hit the "stop" button control, but if it has data on the buffer, I want it to do the database manipulation to all the data on the buffer and then exit so I do not lose any information.

 

Thank you.

 

Gerardo

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

Your queue is handling the collection of data from the part of your programming handling the com ports and forwarding it to other parts of your program.  You need to have another mechanism so your code can notify the Com port handling loop or loops to stop doing that.

 

Notifier, functional global variable, action engine, local variable globabl variable, .....  possibly more ways to do this.

0 Kudos
Message 2 of 3
(2,338 Views)
Solution
Accepted by topic author Gerardo09

Since you have a queue, why not simply add a boolean to your queue (ie: cluster) that you change it's value when the stop button is pushed.  It will advise the other part of the program to process the remaining data and then stop.  Very simple with little overhead.

 

R

Message 3 of 3
(2,332 Views)