LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

# of elements in queue

Solved!
Go to solution

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

0 Kudos
Message 1 of 36
(3,345 Views)

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.

0 Kudos
Message 2 of 36
(3,333 Views)

Are you connecting to the database without any errors?

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 3 of 36
(3,324 Views)

Hi Eric,

 

when the number of elements in the queue is zero your consumer loop stops. So once it's zero, it will never be more than that 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 36
(3,321 Views)

What are you ultimately trying to do with the application?

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 5 of 36
(3,318 Views)

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.

0 Kudos
Message 6 of 36
(3,317 Views)

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,

0 Kudos
Message 7 of 36
(3,316 Views)

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.


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
0 Kudos
Message 8 of 36
(3,300 Views)

@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.

0 Kudos
Message 9 of 36
(3,281 Views)

@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?

 

0 Kudos
Message 10 of 36
(3,276 Views)