11-16-2011 12:00 PM
Dear all,
I am having some problem as abovementioned.
Care to advice?
Thanks in advance
Best regards,
Vincent
11-16-2011 12:14 PM
What problems are you having?
I can see several problems. Obtaing a queue and destroying it on every iteration of the while loop is a bad idea.
You have two Dequeue functions waiting, but you only enqueue a data value to one of them. The corresponding dequeue function will move on, but the other one will wait forever for data that will never be enqueued. (or it may just error out when the queue goes invalid when the queue reference is destroyed.)
I suggest you read the forums for producer/consumer architecture, and look in the example finder for queue examples. Queues are used to pass data between different loops in order without data loss. I don't know what you are trying to accomplish with using the queue functions as you are in a single loop. The queues are just complicating things for no purpose when it seems like all you need to do is use wires to pass out the boolean values.
11-16-2011 01:39 PM
Dear Ravens, what I am trying to achieve is such:
Would you give me some pointer? Here I am asking for 2 queues. Is there a ceiling for number of queues to appear in a single VI?
Look forward to your reply
best regards,
Vincent
11-16-2011 01:56 PM
There is no limit to the number of queues.
The problem is you only have one while loop in your program.
If you are using 2 queues, you actually need 3 while loops. One that contains the event structure and enqueues data to either or both queues.
Each of the other loops contains a dequeue function for one of the queues. Look at Producer/Consumer architecture examples.
11-16-2011 02:00 PM - edited 11-16-2011 02:01 PM
Any queue you use should only have ONE process which dequeues elements. You can have multiple tasks enqueuing data but you should only have one task reading from the queue.
If you want a single UI tasks (which is a good idea BTW) and parallel tasks for processing you will either need to create a separate queue for each parallel task to receive data/commands, use a notifier if you need to broadcast the data/command to all tasks or use event structures within the parallel tasks and use user events. The subtasks event structures would only register for it's own user events. They would not deal with any UI events.
BTW, the code you posted above would not accomplish what you wanted since all of your processing is occuring within a single while loop. You will have to wait for ALL the code to complete before you execute a second iteration of the loop.