LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what parameter to use for queue in event structure

I have a queue that is consistently updated with values from an FPGA via a telnet connection.

 

Right now I have a loop that polls the queue constantly and processes anything that's in it.  I was thinking a better design practice would be to have an event structure that processes queue elements in it anytime there is something in the queue (as opposed to polling).

 

However, I'm not sure how to accomplish this.  Right now the only thing I can think of is to have a variable that stores the queue size and run the event structure based on a change in the value of that variable.  But this defeats the purpose cause I think I'd have to poll the queue constantly to determine it's size.

 

On the other hand, values are arriving constantly in the queue, so maybe polling it is the best way.

 

Thoughts?

0 Kudos
Message 1 of 7
(3,085 Views)

Hi,

 

the "dequeue" function has a timeout parameter. Wire -1 or nothing, and your program will do nothing as long as no new data arrives in your queue

Giuliano Franchetto
Student at the l'Ecole Nationale Supérieure des Mines de Saint-Etienne, cycle ISMIN (FRANCE)
0 Kudos
Message 2 of 7
(3,083 Views)

Oh ok...so I guess I use this in conjunction with the timed out? output??

 

In other words - wire nothing to the timout in ms input, then wire the timed out? output to a case structure that executes when timed out? == FALSE

 

correct?

0 Kudos
Message 3 of 7
(3,076 Views)

@bmishoe wrote:

I have a queue that is consistently updated with values from an FPGA via a telnet connection.

 

Right now I have a loop that polls the queue constantly and processes anything that's in it.  I was thinking a better design practice would be to have an event structure that processes queue elements in it anytime there is something in the queue (as opposed to polling).

 

However, I'm not sure how to accomplish this.  Right now the only thing I can think of is to have a variable that stores the queue size and run the event structure based on a change in the value of that variable.  But this defeats the purpose cause I think I'd have to poll the queue constantly to determine it's size.

 

On the other hand, values are arriving constantly in the queue, so maybe polling it is the best way.

 

Thoughts?


I don't understand about "polling" the queue.  Without a timeout, the dequeue will just sit around and wait for something to be put in the queue.  It doesn't "poll."  You shouldn't need an event structure - or anything else, for that matter - to keep it from "polling."

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 7
(3,066 Views)

Allow me to clarify...I inherited this code from someone else.  There's a while loop set up with a timer, and on each iteration it dequeues an element and then processes it.  This code runs every 10 ms.  So if nothing's in the queue then obviously nothing happens...but I was looking for a way to get rid of the while loop.

 

So right now, it's hierarchically (sp?) like this:

while loop->dequeue->case structure

 

So you're saying I can get rid of the while loop and the dequeue will execute of its own accord (if I don't have a timeout hooked up) whenever an element arrives, right?

0 Kudos
Message 5 of 7
(3,059 Views)

@bmishoe wrote:

Oh ok...so I guess I use this in conjunction with the timed out? output??

 

In other words - wire nothing to the timout in ms input, then wire the timed out? output to a case structure that executes when timed out? == FALSE

 

correct?


No, you don't have to do anything.  It will just sit there until something gets put in the queue.  You probably need to go and brush up on dataflow programming.

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 6 of 7
(3,054 Views)

I suggest reading up on the Producer/Consumer architecture.  If you don't wire the timeout (ms) input, then the dequeue will wait for data to enter the queue.  You can then process the data the was dequeued.  You will need a while loop to repeat the "wait for data and process incoming data".

 

Maybe it would help your cause if you posted the code so we can get a little better context.



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 7 of 7
(3,028 Views)