LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Swapping VIs in and out of a subpanel

I have a large application that uses subpanels to display a large number of possible HMI VIs, one at a time.  The LabVIEW example "Multiple VIs in a Subpanel" launches all the VIs at the start of execution and allows them to keep running in the background as they are swapped in and out of the subpanel.  Instead, I want to abort and remove from memory all but the VI currently displayed in the subpanel.  Some of my HMI VIs are computation intensive and/or involve communication to other devices that only need to occur if someone is looking at that VI.  I have created the attached simple project to illustrate what I am trying to do.  It is a modified version of the NI example project.  I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it.  However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel.  This makes no sense to me, since the Insert VI method is acting on a completely different reference.  It seems like a bug in LabVIEW itself, but maybe I am missing something.  Can anyone tell me what is going on?

 

Note that my VIs are set to be re-entrant, because I may have multiple monitors and therefore multiple subpanels displaying the same VI simultaneously.

Steve Drouilhet
0 Kudos
Message 1 of 10
(205 Views)

I can't see your block diagram because it's position is beyond the limits of my screen.

0 Kudos
Message 2 of 10
(178 Views)

If you close the reference after calling Remove VI the error doesn't seem to happen. 

avogadro5_0-1736198531440.png

 

0 Kudos
Message 3 of 10
(169 Views)

Not according to what I am seeing.  If I Remove VI before closing the reference, then the Close Reference.vi throws error 1026.

 

Drouilhet_0-1736199801639.png

 

Steve Drouilhet
0 Kudos
Message 4 of 10
(161 Views)

@Drouilhet wrote:

Instead, I want to abort and remove from memory all but the VI currently displayed in the subpanel. 


Not sure how your architecture is set up, but a suggestion. Do not use the Abort VI method to close your VI. Instead send a message to your VI to stop. That way, any references in it, memory structures, etc, can be gracefully exited. Rather than use the Run VI method, use the more modern Call and Forget Method, from that call you close the VI reference directly, so no need to close it later.

Message 5 of 10
(160 Views)

Note that you won't see this behavior when the first VI loads on startup.  It's only when you select a different VI.

Steve Drouilhet
0 Kudos
Message 6 of 10
(155 Views)

@Drouilhet wrote:

Not according to what I am seeing.  If I Remove VI before closing the reference, then the Close Reference.vi throws error 1026.

 

Drouilhet_0-1736199801639.png

 


You'll note that's a different error: apparently removing the VI closes the reference previously obtained from "insert vi." So explicitly closing that reference does nothing.

0 Kudos
Message 7 of 10
(150 Views)

@Drouilhet wrote:

 I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it.  However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel. 


You need to close all references to the VI. An open (or hidden!) front panel, in a 
SubPanel or not, is also a reference...

 

Closing a reference doesn't automatically remove it from a SubPanel. If the panel is open, closing a reference doesn't close the panel.

 

So, you need to close all references and close the panel or remove the panel from the subpanel.

 

Of course, it would be convenient to get the subpanel reference from the VI reference, but it has been decided that that's a horrible idea.

0 Kudos
Message 8 of 10
(81 Views)

wiebe@CARYA wrote:

@Drouilhet wrote:

 I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it.  However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel. 


 

Of course, it would be convenient to get the subpanel reference from the VI reference, but it has been decided that that's a horrible idea.


You can get the VI ref from the Subpanel, i just learned ...

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(77 Views)
0 Kudos
Message 10 of 10
(31 Views)