01-23-2019 11:29 AM
I am using LabVIEW 2018 and have a large application that can load and unload SubVIs from multiple subpanel containers. I can start the subVIs and I can shut them down programmatically (not Abort). However I can't seem to find a way to load the subVI in the background so it is running but not visible and then load it into a subpanel when the user is ready to view it. The specific problem I am trying to solve is a Graphs subVI. The Graphs subVI plots a default set of parameters selected by the user (and saved to an ini file) for X amount of time (buffer length). But the graphing doesn't start until the user loads the SubVI into the subpanel container meaning there is no history in the buffer on first call. If I could launch the Graphs.vi in the background during startup then there would be data in the buffer when the user selects that subVI for display in the subpanel. The core problem seems to be that a running vi can't be inserted into a subpanel. Is there a way around this?
Solved! Go to Solution.
01-23-2019 11:45 AM
You definitely can insert a running VI into a SubPanel. Have you tried closing the FP first?
01-24-2019 06:09 AM
What Neil said. But remember that if nobody else has an active reference to the sub-vi open, closing its panel will abort the VI (I've re-learned this fact several times over the years).
Make sure somewhere in the system the VI is either statically referenced or someone has opened a valid reference to the specific instance of the VI.
01-24-2019 08:33 AM
Ok. Thank you both for the replies. I thought I was doing that but I will double check that I'm not missing it somewhere. Is holding the SubVI reference in a FGV enough? Stay tuned...
01-24-2019 08:33 AM - edited 01-24-2019 08:34 AM
To add to the other responses, here is what I would suggest:
To "preload" the VI you can use the Front Panel.Open method to set the front panel state to hidden with activate = false after starting the VI programmatically. Make sure to keep track of the VI's reference so that it doesn't inadvertently trigger an auto abort. Prior to loading the hidden VI's front panel into the subpanel, you will need to use a property node and the VI's reference to check the front panel state. If "hidden", set to "closed" using the property node prior to performing the sub-panel's insert VI operation.
At least as of LabVIEW 2015 SP1, I have found that inserting a hidden VI into a subpanel object will cause the owning VI (of the subpanel) to inherit the hidden front panel state of the inserted VI and completely disappear.
01-24-2019 08:58 AM - edited 01-24-2019 08:58 AM
It's less important WHERE you store the reference (well, it is if you want to avoid reference leaks), it's only important that some code which stays running beyond the lifetime of your sub-VI has performed an "Open VI Reference" or has a static reference to the VI. As a contrasting position: getting the value of "This VI" static reference from the sub-vi itself via some asynchronous method when the sub-VI is running won't help because the lifetime of this reference is tied to the VI whose FP you will be closing and (potentially) aborting. The VI who retrieves the reference must get its own reference and remain running beyond the "FP.Close" of the sub-VI. You need to increase the refcount for the VI.
I know I've made a terrible job of explaining that. Sorry.
01-25-2019 10:54 AM
Great advice. I was putting together an example VI I could post here with the solution (have to create a simpler version without all the proprietary stuff) and sure enough I got bit by this. However, I had to Remove the VI from the subpanel then change its status to hidden to keep it running in the background. Just a few bugs left to work out before I post an example.
Thanks everyone for the help finding the last few pieces of the puzzle for me.
Zynali