06-30-2022 09:12 AM
Is there a priority between "Preview Queue Elements", "Get Queue Status" and "Dequeue"?
If the speed of a producer to produce data is much slower than its consumer, then the data would be removed by the "dequeue" function instantly after it was sent into the queue. However, the description of the "Preview Queue Elements" function says "Returns the element at the front of the queue without removing the element from the queue". So, if I use "Preview Queue Elements" in Loop1 and use "Dequeue" in Loop2 (Loop1 and Loop2 are parallel and there's no explicit line between them to indicate the sequence of data flow), can I get the same data from these two functions in the two loops constantly? or may that be determined by the different time cost in those 2 loops?
A similar question is when I set "Get Queue Status" in loop1 to get the number of elements in this queue and set "Dequeue" in loop2 to get the first element in the queue, and the speed of production is much faster than that of consume, what result I can get in Loop1? 1 or 0?
06-30-2022 09:28 AM
If you are sending data to two loops, just use two Queues, rather than anything complicated using one Queue.
06-30-2022 09:30 AM
There is no guarantee if your parallel Preview Queue or Get Queue Status will see the element before the Dequeue removes it. It sounds like you should be using 2 queues or possibly a queue and a notifier to get your data passed around to where it needs to go.
06-30-2022 09:36 AM - edited 06-30-2022 09:37 AM
@Rickey.SKD wrote:
Is there a priority between "Preview Queue Elements", "Get Queue Status" and "Dequeue"?
If the speed of a producer to produce data is much slower than its consumer, then the data would be removed by the "dequeue" function instantly after it was sent into the queue. However, the description of the "Preview Queue Elements" function says "Returns the element at the front of the queue without removing the element from the queue". So, if I use "Preview Queue Elements" in Loop1 and use "Dequeue" in Loop2 (Loop1 and Loop2 are parallel and there's no explicit line between them to indicate the sequence of data flow), can I get the same data from these two functions in the two loops constantly? or may that be determined by the different time cost in those 2 loops?
A similar question is when I set "Get Queue Status" in loop1 to get the number of elements in this queue and set "Dequeue" in loop2 to get the first element in the queue, and the speed of production is much faster than that of consume, what result I can get in Loop1? 1 or 0?
These questions make me want to discuss the architecture you are trying to implement where questions like this are relevant.
Edit: I guess things have progressed to this point between the time that I started thi reply to the time I pressed the POST button.
06-30-2022 10:02 AM
I would suggest User Events, make multiple loops and have each loop subscribe to the events you want.
06-30-2022 10:13 AM
And I'll ask the question no one else did.
Why do you want to send the same information to two independently running loops? (There may be a good reason but it's uncommon and a mutlticast channel wire would be safer)
The most common reasons I can think of are "Measurement and Logging" projects of either continuous or finite variety. ALL of those Project Templates use 2 Queues one for display / analysis, and the other for logging to file ( although with DAQmx you can bury the logging in the Acquisition by enabling DAQmx Logging)
Didn't you start from a Template Project?
07-01-2022 10:42 AM
07-01-2022 10:44 AM
Thanks a lot!
07-01-2022 10:46 AM
In the 1st loop, I put an event structure in it to set my motorized stage on different points. On each page, I send the information about my stage to the queue named “Stage Inf” after the position was changed.
In the 2nd loop, I dequeue the “Stage Inf” to get my stage information and output them to a display control on the front panel.
In 1st loop, there’s a “special” page that sends the stage to a special position and triggers a sub-loop in the 3rd loop. At the start of the sub-loop, the “Stage information” I got from the 1st loop needs to be sent into the shift register to initialize it. I want to use “Preview Queue Elements” function to get the information, but in the 2nd loop, this queue has been dequeued so I can get nothing here.
07-01-2022 10:56 AM
I'm a rookie to this forum, could you please tell me how to cite those previous replies like what u did here? Thank you!