09-30-2013 11:19 PM
Have you tried my VIs?
10-01-2013 05:31 PM
It's true that you need all while loops in the subvi to stop for the sub vi to properly close and prevent the main vi from hanging. For the event case, it would be better to have one event case structure that handles all events. To add events to your event case structure, right-click and then select "Edit Events Handled by This Case" or "Add Events Handled by this Case". In summary, in your main vi you should have one event case structure that handles both the default case and your "Exit" Value Change case, and a similar set up in the sub vi. This would reduce the number of while loops in your code, which I suspect is causing some of the freezing.
10-01-2013 05:34 PM
Another idea, in your sub vi, you could try linking the Cancel Boolean control to all the stop conditions, rather than using a local variable. Values can pass through while loops. However, that will force the while loops to stop in a certain order, which you may or may not care about.
10-01-2013 10:25 PM
@TBirkulosis wrote:
Another idea, in your sub vi, you could try linking the Cancel Boolean control to all the stop conditions, rather than using a local variable. Values can pass through while loops. However, that will force the while loops to stop in a certain order, which you may or may not care about.
Can you demonstrate what you mean by these statements? What you are describing sounds like you are breaking data flow and will keep parallel while loops from even beginning to start until prior ones finish.
10-02-2013 08:08 AM
It's correct that you can't connect while loops that you want to run in parallel.
Here is a good example of how to close the sub vi once the cancel button is finished: https://decibel.ni.com/content/docs/DOC-10571
In this code, instead of having the VI's FP.close invoke node in a while loop, they have it in a flat sequence structure connected to the while loop. I made example code that implements this. I noticed that the Mechanical Action associated with the Stop Boolean (or the Cancel Boolean in your case) effected if the value stayed true when pressed. I had to have the Mechanical Action of my Stop button set to Switch When Pressed for it to work.
10-02-2013 08:11 AM
Actually, looking at your code, I think it is the Mechanical Action of your Cancel button that is failing. You have it set to Switch Until Released. The Cancel Boolean is only True when pressed. You should changed to Switch When Pressed for it to function correctly. You can change the mechanical action by right-clicking on the Boolean and selecting Mechanical Action. Try that and let me know if it works!
04-29-2016 03:39 AM
Thanks Ranjeet_Singh for your VI,
However, I am dealing with subvis in which I need to pass data from the main VI to the subVIs. I modified your main and sub VIs to pass data, and now the subVI stops, but does not closes. (see the attached files).
Do you know how can I fix this?
Thanks,
Daniel
05-02-2016 01:07 PM
Hi Daniel,
I noticed that you are not opening or closing your reference in your main VI. Check out this tutorial about calling a VI by reference. It talks about closing references and best practices for calling a VI by reference.
http://www.ni.com/tutorial/3929/en/
Best,
Doug