LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enqueue/dequeue problem

Solved!
Go to solution
Solution
Accepted by topic author hassan2019

@hassan2019 wrote:

i would really appreciate if you give me a hint about handling of queues ans files. no doubt u raised valids points but u must give me some alternate solutions.

as far as tcp reference is concerned that is the requirement of my programs.u may ignore it

but  for queues and file handling i need ur kind suggestions

thanks


1. Avoid naming your queues.   There are fights over this, but I find they will cause conflicts unless you are EXTREMELY careful.

2. Create your queues before the loops even start.  Pass in the desired queue to the loops that need access to it.  Close the queues after all of the loops have stopped.

3. Similarly, you are better off by opening/creating your file before the logging loop, closing the file after the logging loop, and writing inside of the loop.

4. From a structural standpoint, you will be a lot better off if you turn each of your loops into their own VIs.  The top level VI can initialize the queues and pass them into the subVIs.  This will help by a) shrinking your diagram, making it more readable, and b) segregating the code, making it easier to debug and reuse.

5. As an alternative to queues, you could look into using Channel Wires.  I'm not a fan of them, but there are plenty of advocates out there, and parallel processing with subVIs is where they seem to work the best.


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 11 of 17
(1,783 Views)

bundles of thanks @crossrulz ur guidelines are very much realistic and i will definitely implement them to run my VI smoothly.

one more question if u could asnwer it.

my CPU is taking too much resources e.g. around 25%  is it normal or not .if not then how to reduce this to avoid over burden on CPU.

secondly why my server VI gets hanged after running contineously 6,7 hours and i have to shut it down using task manager's end process

0 Kudos
Message 12 of 17
(1,763 Views)

u said avoid naming queues. if i dont give them any name then in my VI, i am using 2 queues e.g. "queue" and "myqueue" how would labview will get to know which queue reference shall it have to pass on to relevent dequeue pallet.

please guide me in this regard.because in labview's given examples Labview it self uses names for queues

0 Kudos
Message 13 of 17
(1,760 Views)

I do name queues in my code sometimes. But it's not necessary nor desirable to do this in a single vi. Nor is desirable to open and close them for each operation.

Open your queues once outside the loops and close them once when the vi terminates.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 14 of 17
(1,740 Views)

@hassan2019 wrote:

u said avoid naming queues. if i dont give them any name then in my VI, i am using 2 queues e.g. "queue" and "myqueue" how would labview will get to know which queue reference shall it have to pass on to relevent dequeue pallet.

please guide me in this regard.because in labview's given examples Labview it self uses names for queues


Use the wires. Don't open and close the queue inside the loop. Open the queue when you start the program and then feed the queue reference to the loops that need it. Close the queue when you stop the program. When you create the queue that wire that comes out on the other side (the one that you pass to the Enqueue and Dequeue) is the queue reference. I often give queues a unique name, but for me it's just a way to document the queue when I create it and make it easier to verify that I'm getting the correct queue reference in debugging. I do not use that queue name as a way to open the same queue in another part of the code. 

0 Kudos
Message 15 of 17
(1,731 Views)

@hassan2019 wrote:

u said avoid naming queues. if i dont give them any name then in my VI, i am using 2 queues e.g. "queue" and "myqueue" how would labview will get to know which queue reference shall it have to pass on to relevent dequeue pallet.

 


"LabVIEW" wouldn't know, but you, the programmer, should know!  The "identity" of the Queue is in the Queue Reference "wire".  Within a VI, just follow the wire going into the Dequeue Element function to find the Create Queue function that created it.  If you want, you can right-click on the Queue wire and give it a "Label" to help you remember which wire is which (note that if the Queue elements are sufficiently different, like a Queue of Strings vs a Queue of Dbls, the Queue Reference wires will look different).

Bob Schor

0 Kudos
Message 16 of 17
(1,723 Views)

thanks everyone. the problem has been solved by initializing queues and files outside the loops.

everybody helped me alot and made me understand alot of new things.

stay blessed everyone.

Best Regards

0 Kudos
Message 17 of 17
(1,680 Views)