04-25-2006 07:51 AM
04-25-2006 09:49 AM
hi there
i think it depends on your application: if you're forced to maintain exact timing and priority i'd use a timed loop for the producer loop. if not, i'd use a standard loop with "wait ms" or "wait until ms multiple" function.
cause the consumer loop waits fot the event that there is some data in the queue until "time out ms" i'd use a standard loop for the consumer without "wait ms" or "wait for ms multiple". if you'd use a timed loop for the consumer you would waste the rest of the time of one single turn doing nothing.
04-25-2006 10:14 AM
Dear Chris,
thank you for your assistance very much.
I am going to use Producer/Consumer design pattern for design user interface (Producer) and test sequence (Consumer).
After your response my question can be rebuilt like
What is better to use queue with until "time out ms" (by the way in Producer/Consumer design pattern time out value is -1, no time out) or to build Consumer around timed loop and queue without until "time out ms"?
Another words, if I will design several Consumers than queue with until "time out ms" will stop execution in other Consumers or not?
With best regards,
Mikhail
04-25-2006 10:34 AM
04-25-2006 10:57 AM
Dear Chris,
thank you for your assistance.
I am going to use unique queue for each consumer. I have got several rather slow devices (magnetic field facility, temperature cryostat, etc). It is the reason why I would like to use several consumer to be able to control (adjust) several devices simultaneously.
With best regards,
Mikhail Kozlov
04-25-2006 11:18 AM
take a look at the attachment.
you can use one single consumer loop with one single queue when you supply the datas origin with the queue data.
advantage: minimized code, minimized changes in code when to add a new data origin
disadvantage: data is processed only serial
04-25-2006 11:31 AM
Dear Chris,
thank you for your assistance.
In my case I have a need in a code that allows me to run several consumers at the same time. For example one consumer control sweeping of magnetic field value defined by Producer (user), another control sweeping of temperature value defined by Producer (user). It is the reason why I would like to be sure that wait for timeout does not stop another consumer loop.
With best regards,
Mikhail Kozlov
04-27-2006 01:07 PM
I have discovered that Producer/Consumer design pattern (as it is suggested in LabView 😎 generated error message if one stop program since Consumer loop aborted by error.
Is it possible to abort Consumer loop without rising error?
With best regards,
Mikhail Kozlov
04-28-2006 03:06 AM
hi there,
you can wait for new queue elements in one loop without having to wait for "time out ms" to ellapse in another parallel loop.
to abort waiting simply release the queue. see online help for "Deque Element" - function:
"If queue becomes invalid (for example, the queue reference is released), the function stops waiting and returns error code 1122"
04-28-2006 03:14 AM
As you mentioned
"If queue becomes invalid (for example, the queue reference is released), the function stops waiting and returns error code 1122"
it means that I have received an error message after stoping Producer/Consumer if I use error handler VI. In general it is possible to remove this error message however I am looking for a better solution. I will try to send by queue a stop command to Consumer loop.