10-03-2017 08:49 AM
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).
10-03-2017 09:01 AM
10-03-2017 09:06 AM
here
10-03-2017 09:34 AM
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.
10-03-2017 09:36 AM
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.
10-03-2017 09:39 AM - edited 10-03-2017 09:41 AM
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.