03-07-2023 04:36 AM
Hi Sir,
Not sure why always report this kind of error:
My producer is creating txt file in A folder;
My consumer is move the txt file one by one to B folder;
Is it kind of timing issue ?
Also which one should I wire to element ?
Thanks.
Solved! Go to Solution.
03-07-2023 05:15 AM
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.
03-07-2023 05:37 AM
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.
03-07-2023 05:43 AM
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.
03-07-2023 05:56 AM
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.
03-07-2023 09:26 AM
@Basjong53 wrote:
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.
03-07-2023 09:51 AM
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.
03-08-2023 09:04 AM
@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.
03-08-2023 09:08 AM
Why don't you send the generated Filename as queue data?