04-27-2012 08:55 AM
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
04-27-2012 09:11 AM - edited 04-27-2012 09:11 AM
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
04-27-2012 09:45 AM
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
04-27-2012 10:32 AM
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
04-30-2012 02:50 AM
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
05-04-2012 04:52 AM
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.