From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue inside a subVI

Hi!

 

I need your help to make a subVI in which there's a queue.

 

In the main vi, within a loop, a value is sended to the subvi (i.e. to the queue).  

 

The problem is that the loop in the main vi is stuck because it waits for the subvi return.

 

Can you please help me?

 

Best,

Philippe

Download All
Message 1 of 6
(4,056 Views)

This looks like you are almost there - however the Producer/Consumer design pattern has seperate loops for the Producer or Consumer.

 

I would take a look at this:  Application Design Patterns:  Producer/Consumer


Regards,

Peter D

0 Kudos
Message 2 of 6
(4,054 Views)

Ok, but how can I have this subvi working?  I want the new data points to be added to the queue, and when it's possible, to be processed (and then removed) in a consumer loop (inside the subvi).

 

Best,

Philippe

0 Kudos
Message 3 of 6
(4,049 Views)

Look at Pete's link. You should create the queue in the Main vi, and send it to the sub-vi as a input outside the main loop. The sub vi will consume items until it's destroyed, which you'll do in the main vi after leaving the main loop.

/Y 

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

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 6
(4,038 Views)

Firstly, I designed that with a producer-consumer pattern in a same vi.  In the consumer loop, data is sended through the network; but it is sometimes off, so the queue is filled with data (from producer loop), and when the network becomes available, the queue is flushed.

 

I want to know if it's possible to do the same with a subvi?

 

I can't wait the subvi loop finished, because maybe it will not, and I loose the data from the main vi.  

 

Do you understand what I'm trying to do?

 

Best,

Philippe

0 Kudos
Message 5 of 6
(4,016 Views)

Hello Philippe,

 

Did you follow the advise that Peter D provided and implement it?

If yes, can you send your latest files?

 

The problem with the code in the first post is not caused by the subVI.

The problem/waiting happens because you have 2 loops inside of eachother instead of 2 loops in parallel (2 parallel loops are used in the producer/consumer design pattern):

- Main VI contains one loop

- Inside your main VI you have another Vi that also contains a loop.

- Result: You have a loop embedded/nested inside another loop instead of 2 parallel loops.

 

What you're trying to do should be possible if you follow the design pattern in Peter's link.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 6 of 6
(3,992 Views)