Showing results for 
Search instead for 
Did you mean: 

Subvi as Consumer

A couple of options:


1. Use the Asynchronous Call By Reference to run your subVI.  Going with that route, you can directly pass in the queue reference into the VI call and just have the subVI use that queue reference.


2. Use an Action Engine to maintain your queue.  Let the subVI maintain the queue (open, read, and close) while your main VI can just send via the queue.


A general rule: Do NOT allow the producers maintain the queue.  The consumer (the loop that reads from the queue) should maintain the queue.  Bad things happen when the producer stops and closes the queue while the consumer is still processing messages.  This becomes especially true if you do things properly and you send the stop command through the queue (the stop message can be completely missed if the queue was destroyed before the stop message can be read).

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
Message 11 of 16

@volfi wrote:

sorry, now.

Still missing.

0 Kudos
Message 12 of 16


Download All
0 Kudos
Message 13 of 16

Your Init case in the consumer loop has an infinite while loop in it.  That Init case will never end, so it will never get a chance to process any more messages out of the queue.  The queue will just fill up.

0 Kudos
Message 14 of 16

then how can I let the VI run without being stuck in the while Loop.If I leave out the while Loop it throws an error.

0 Kudos
Message 15 of 16

What error does it throw?


Once you set the subVI to start running, it should run just fine.  EXCEPT. your subVI is set to have a true in its while loop stop condition.  So that subVI only runs once.


You've created a run once subVI, and have gotten your consumer loop in the main VI stuck in a run forever loop.


PS:  In the subVI don't convert the cluster to an array, then proceed to use extra Index Arrays to break the array apart.  (Index Array is expandable, drag the bottom border down and you'll get more outputs, and by default it will be index 0, 1, 2, .....)


But all you need is an Unbundle Cluster to get the to cluster elements and get rid of the array manipulation all together.

Message 16 of 16