LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deque Element Error

Solved!
Go to solution

Hi Sir, 

 

Not sure why always report this kind of error:

 

Brzhou_0-1678185161428.png

My producer is creating txt file in A folder;

My consumer is move the txt file one by one to B folder;

 

 

Brzhou_1-1678185314396.png

 

 

Is it kind of timing issue ?

Also which one should I wire to element ?

Thanks.

Learning from other people
0 Kudos
Message 1 of 9
(1,784 Views)

The error occurs because you are destroying the queue reference. When you do this, the dequeue element vi goes in error and stops your loop as well as displaying this error.

 

2 other things:

Remove the wait vi in the bottom loop, you are already doing your timing with the queue.

Use the error terminals to control data flow. Right now, the read file isn't waiting on your dequeue.

0 Kudos
Message 2 of 9
(1,768 Views)

Hi Sir, 

 

Thanks for your quick response.

 

1.Remove the wait vi in the bottom loop, you are already doing your timing with the queue.

-->removed, works fine.

 

2. Use the error terminals to control data flow. Right now, the read file isn't waiting on your dequeue.

-->I do not quite understand how to wire, could you give more indication ? 

 

3.The error occurs because you are destroying the queue reference

-->So the reference should be something ensure the execution is done for producer ?

 

Thanks.

Learning from other people
0 Kudos
Message 3 of 9
(1,758 Views)
Solution
Accepted by Brzhou

Basjong53_0-1678189274058.png

Wire the error like this.

 

It's fine to destroy the queue reference to stop a loop with a dequeue element vi. Just ignore the error that the dequeue element vi gives when you destroy the queue, as you only use the error to stop the loop.

 

0 Kudos
Message 4 of 9
(1,754 Views)

Updated:

So the "IN", it is better to be the end of producer frame;

And the "OUT", it is better to be the beginning of the consumer frame, right ?

Thanks.

Brzhou_0-1678190123573.png

 

Learning from other people
0 Kudos
Message 5 of 9
(1,749 Views)

@Basjong53 wrote:

Basjong53_0-1678189274058.png

Wire the error like this.

 

It's fine to destroy the queue reference to stop a loop with a dequeue element vi. Just ignore the error that the dequeue element vi gives when you destroy the queue, as you only use the error to stop the loop.

 


It's NOT "fine" to destroy the queue to exit the loop!  Any elements that were waiting to be dequeued will be LOST.  You'll have incomplete data.  The heavier the traffic on the queue, the more data you will lose!  And I used to do that a long time ago and someone had to tell ME this before I realized why I was losing data.

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.
Message 6 of 9
(1,702 Views)

Hi Bill, 

 

I am still not quite sure what kind of thing should be wire to "element" ?

and what do you mean by " destroy the queue to exit the loop! " ?

Normally how to exit the loop ?

Thanks.

Learning from other people
0 Kudos
Message 7 of 9
(1,695 Views)

@billko wrote:

@Basjong53 wrote:

It's fine to destroy the queue reference to stop a loop with a dequeue element vi. Just ignore the error that the dequeue element vi gives when you destroy the queue, as you only use the error to stop the loop.

 


It's NOT "fine" to destroy the queue to exit the loop!  Any elements that were waiting to be dequeued will be LOST.  You'll have incomplete data.  The heavier the traffic on the queue, the more data you will lose!  And I used to do that a long time ago and someone had to tell ME this before I realized why I was losing data.


Of course it is not the most elegant way to do it. There many ways to do it better (state machine, message based, simple boolean in queue data type, etc.), but for a simple program like this it really isn't the part to spend too much time on. Hence why I said it was "fine" (I'll put quotes around it this time).

 

The element data type can be anything you need. But as you are not needing any data from the producer loop I suggest to use a boolean as the data type. When the producer loop stops, you send a true value to the queue. The consumer loop is stopped based on this boolean that it receives. When both loops are stopped, then you destroy the queue.

 

Think about how to do this. Think DATAFLOW!!. Hint: user the error wires to enforce dataflow and control the execution order each vi.

Message 8 of 9
(1,630 Views)

Why don't you send the generated Filename as queue data?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(1,628 Views)