11-02-2012 10:30 AM
I'm working on an upcoming project that will need to use a Producer/Consumer loop structure. Right now, I've added a simple test of how I want the VI to work, but I am having one issue. When I run the VI, the "# elements in queue" never increases from time to time. I have used the abort button to stop execution when the Consumer loop is in an endless loop (which I know is bad). I am trying to guarantee that all of the elements are consumed and saved to my database.
Does anyone know what's up with the VI?
Thanks,
Eric
Solved! Go to Solution.
11-02-2012 10:59 AM
I should be more clear on the statement "never increases from time to time", I mean that when I start & run my vi, sometimes the elements in the queue never increases and states zero.
11-02-2012 11:09 AM
Are you connecting to the database without any errors?
11-02-2012 11:10 AM
11-02-2012 11:13 AM
What are you ultimately trying to do with the application?
11-02-2012 11:13 AM
I took the database stuff out so that I could run the VI and it seems to be looking ok.
So I would suggest your problem lies in that direction.
(Have you tried highlighting execution and seeing what happens?)
Modified VI attached.
11-02-2012 11:14 AM - edited 11-02-2012 11:16 AM
Hi Eric,
Try also using your error wires to stop your loops (as an OR). Since you are aborting in your loops, you are missing any potential errors that might help you troubleshoot this.
Like Brandyn said, if you are getting an error connecting to the database, you will be feeding an error into your queue operations as well. Try probing your error wires.
EDIT: GerdW is correct. If you change your consumer logic to # elements = 0 AND stop then you will avoid the case he is describing
Regards,
11-02-2012 11:28 AM
First of all, there is no need for the waits in the consumer loop.
You really shouldn't be looking at the number of elements left in order to determine whether or not to stop. What I do is have a specific message for stopping the consumer loop. In this case, I would probably say if the integer in the cluster is a 0, then stop the loop. So once the producer loop is complete, it sends a "stop command". Once the consumer loop is then complete, you can release the queue. This will guarantee that all of the eleements will be handled by the consumer.
11-02-2012 12:12 PM
@Brandyn wrote:
What are you ultimately trying to do with the application?
I am trying to guarantee that all the information has been processed, or in my case, been placed in a Access database. Basically, if the stop button has been pressed but elements (info) sill remain, I need to continue until all the information has been passed through.
11-02-2012 12:16 PM
@crossrulz wrote:
You really shouldn't be looking at the number of elements left in order to determine whether or not to stop.
May I ask why? Isn't the elements left telling me how many processes are left in the consumer loop?