LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Priority between "Preview Queue Elements", "Get Queue Status" and "Dequeue"?

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?

 

0 Kudos
Message 1 of 12
(1,590 Views)

If you are sending data to two loops, just use two Queues, rather than anything complicated using one Queue.

0 Kudos
Message 2 of 12
(1,582 Views)

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.


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 3 of 12
(1,578 Views)

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

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 12
(1,574 Views)

I would suggest User Events, make multiple loops and have each loop subscribe to the events you want.

0 Kudos
Message 5 of 12
(1,557 Views)

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?


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 12
(1,535 Views)
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. The existence of this trouble encourages me to create this topic for some help and guidance. Actually, on that “special” page, I write my stage information into a local variable and read it to initialize my shift register of the sub-loop, so the operation of my whole program has not been hampered by the trouble described here. But I’m still so curious about whether there’re some better ways to achieve my need. Thank you all for your cordial guidance and help!
0 Kudos
Message 7 of 12
(1,492 Views)

Thanks a lot!

0 Kudos
Message 8 of 12
(1,489 Views)

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

 

0 Kudos
Message 9 of 12
(1,485 Views)

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! 

0 Kudos
Message 10 of 12
(1,477 Views)