LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding producer consumer

Solved!
Go to solution

Good morning everyone,

 

it seems to be that i have a real problem to understand queues and notifiers.

adding a timeout to first dequeue helped that the consumer loop was running. but my states are switching.

So i tested in simple version with notifier. And it had the same effect. attached is the vi (2014)

My understanding is following.

If i´m sending a message or enum queue to the case, the structure is switching. Then the buffer is clear and no input is on the case selector. Now it´s going back to default. 

According to my simplest example with notifiers, how is it possible to hold states?

0 Kudos
Message 11 of 14
(977 Views)
Solution
Accepted by topic author DickerMoby

Problem with band-aids -> they lead to more band aids. This one is easy to fix, but it's just another band-aid.

 

The solution is to fix the architecture. Actually, in the example you put up here, you wouldn't have a problem with no timeout, which is the intended way to use Producer-Consumer.

 

In the 'fixed' VI I attach, I check for timeout. 


GCentral
0 Kudos
Message 12 of 14
(975 Views)
Solution
Accepted by topic author DickerMoby

Assuming I am understanding your problem, what I typically do is hold the timeout in a shift register.  So when a message is received to start acquiring data, the timeout is set to 50 (per your example).  With a string data type, an empty string will be returned from the Dequeue Element if there was a timeout.  So in the "" (empty string) case, you perform the read.  When commanded to stop, set the timeout to -1 (wait forever).



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
Download All
0 Kudos
Message 13 of 14
(968 Views)

Hello everyone,

 

i´m sorry for the late reply.

Thanks to all for the answers and Solutions. I will try and learn more. For first t seems to be good.

So i can think about my generally program structure.

0 Kudos
Message 14 of 14
(947 Views)