LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1122 at dequeue

Hello All,

 

I know this a common problem but can anyone pin point how I can prevent an error 1122 from occurring in my VI? I have tried all manner of rewiring the Close queue vi with no success. 

0 Kudos
Message 1 of 2
(1,912 Views)

When does this error occur?  When running the VI, or only when you try to stop it?

 

It seems like you are killing the queue after the producer loop.  This will then eliminate the queue reference which will cause the error at the dequeue function in the consumer loop.  It looks like you use this error to stop the loop.  The error will pass through and pop up as a dialog box right before your program ends.

 

There are a couple problems with this that I dislike this method for stopping loops.

1.  If you still have data in the queue that is left to be processed, it just got eliminated and will never be processed.

2.  I feel kind of dirty using the error wire for a purpose it was not meant for.  The stoppage of the program should be considered a normal part of program operation and should not generate an error message that you use as a signal.  Save error messages for actual program errors, not normal operations.

 

I recommend moving the Release Queue to after the consumer loop.  In the producer loop, when you are done and want to stop it, sent a final message in the queue that will tell the consumer loop it is done and to stop the consumer loop.  Sometimes that can be a sentinel value like an NaN or an empty array, that would never occur during normal operation.  In your case you are only sending a boolean, so you have only 2 choices (True/False) and both are valid.

 

If I was writing your program, I would send a cluster of two booleans, one would be the data, the other would be boolean that tells whether to stop the loop which would normally be false until you send the final queue element.

 

PS:  Always give your control terminals a label and make them visible on the block diagram as part of good program documentation practices.  You can hide the label on the front panel.  Your upper loop as a boolean with no/empty label.  So when looking at the block diagram, it is impossible to know what that boolean terminal is supposed to mean.

0 Kudos
Message 2 of 2
(1,877 Views)