12-12-2012 03:00 AM - edited 12-12-2012 03:00 AM
I have seen examples of inserting VIs into a subpanel, but when inserting a new VI, the code always removes the current VI and aborts it.
Is there a way to "swap out" a VI for another but keep it running in the background?
Solved! Go to Solution.
12-12-2012 03:26 AM
Removing a VI from a subpanel (either by using the Remove VI method or by inserting another VI) should not cause the VI to abort. The two are unrelated. Are you sure you're not stopping or aborting the VI using another method? Can you create a simple example showing the problem?
12-12-2012 03:51 AM - edited 12-12-2012 03:54 AM
When you insert a sub vi into your sub panel generally it won't run you have to invoke a run method to run that vi and the same way it won't abort the vi. But generally we use to stop the vi using the set control value method because when you try to insert the same vi again it will give you an error. The sub panel will only insert a vi which is not running.
12-12-2012 04:11 AM
P@Anand wrote:
When you insert a sub vi into your sub panel generally it won't run you have to invoke a run method to run that vi and the same way it won't abort the vi. But generally we use to stop the vi using the set control value method because when you try to insert the same vi again it will give you an error. The sub panel will only insert a vi which is not running.
I'm getting the "VI in the wrong state" error when I try to swap two VIs back and forth. It only works the first time the VI is inserted into the subpanel (unless it's stopped). I was hoping I could swap VIs in and out of the subpanel while they continue to run. I have a bunch of clone VIs that the user wants to display. I wanted a method of keeping the screen size down to something reasonable.
12-12-2012 04:25 AM
So you can check the state of the vi before inserting it into the sub panel that should solve your issue. When you want to insert a clone instanse use the option in the open vi reference as 0x08 (see detailed help of open vi reference) so when you open it again it won't give you error since you will open the next clone instance.
12-12-2012 04:55 AM
It really does work and here's a quick example (2009). Changing the numeric value creates a new VI or runs an existing one and you can see from the counter that the VIs keep running even when you switch.
12-12-2012 06:03 PM
Looks like my main problem was not keeping the VI reference in memory as you're doing in your example using attributes.
Thanks tst, putting this in my "toolkit".
12-12-2012 11:39 PM - edited 12-12-2012 11:43 PM
Disregard my last post, my problem was not looking at the execution state of the VI before calling the Run method (noob mistake) and then inserting it into the sub-panel. If already running just insert it. Now I can swap VIs in and out while they continue to do "work" uninterrupted. Cool.