I have a re-entrant vi that will not close its reference. My program runs an experiment, and when the experiment finishes, I use the FP.Open property node (w/ a False wired to it) and a Close Reference to close the VI and reference automatically. If I go into Windows Explorer to reopen the VI for editing, I receive a popup " A VI in memory with the same name cannot be replaced because it is in use. Click OK to open the VI in memory."
Now if stop my program part way thru the experiment by manually pushing the Quit button (which executes the same FP.Open and Close Reference), and try to reopen the VI thru Explorer, there is no popup and the VI opens without a hitch. I can't figure out why there is this difference in behavior, or why I cannot close VI reference.
Is re-entrancy the issue?
Solved! Go to Solution.
Is it possible that the referenced VI is still running? If so, make sure that the referenced VI has stopped before closing the panel (and its reference) otherwise, the VI will keep running in memory but you will have to pick up its reference by some "dirty tricks" (well, they are not dirty, but a little overelaborate....)
As seen in the previously attached screen capture, the VI STOP button triggers the event. It goes thru user dialog before leaving the event structure and terminating the while loop, followed by the false-fed FP.Open and Close Reference. As I understand it, this should be stopping the VI and wiping the reference.
I mentioned before that if I manually push the the VI STOP button to end an experiment, the code executes fine. If I let the code stop the program by allowing a full experiment run, the VI closes but the reference does not. I did fail to mention before, that if the code runs a full experiment, the VI STOP event is triggered by a Value Signaling property node.
So, my thoughts are that the re-entrancy of this program or the Value Signaling property node could be causing the issue.
If you place a breakpoint/probe on the reference that goes between the VI property node and the close reference VI, does it execute if you allow the experiment to complete? Also, there appears to be more to your code that could be causing this problem, would you be able to post your code in full?
I did place the breakpoint in between the property node and the close reference, and the code executed and behaved how I desire. Since I added a breakpoint and it came while the code is trying to end, LV prompted me if I wanted to save. Which confuses me further. It seems that for the reference to be cleared, it requires some user interaction. If I manually close the experiment/program and if I add a breakpoint, I achieve the desired result. But if I allow full experimental run, it behaves otherwise. I wonder if it is a timing issue...
Attached is my code minus subVI's. The VI I am having issues with is called by another, main VI which handles most communication to a series of furnaces.
Just so I understand correctly, the VI you sent me is a subVI itself inside of a larger program? It appears that you are trying to close a reference to the furnace control VI while you are still inside the VI. This may inherently cause problems. If this is a subVI then you will want to close the reference to it outside of the subVI. However, even this is only really needed when you are opening a reference to a particular VI. Under normal circumstances, you could call a subVI in your program and let LabVIEW handle the references. For example:
This could be my entire program - no open or close references required. Likewise, I don't see how this close reference function applies in this case.
I hope that this helps but if there is something I am missing, please just let me know!
No, this program is not a subVI. It is simply called by another VI (called Main Panel) via invoke nodes. The Main Panel handles communication between the computer and Watlow brand furnace controllers. The Main Panel calls Furnace Control, which sends temperature routines to the furnace controllers. The Main Panel is always running, while Furnace Control is reentrant and a new clone is created for each furnace that I wish to run an experiment on. I cannot send temperature profiles or even operate FurnaceControl unless the MainPanel is running.
I initially started using the Close VI reference following the FP.Open property node because I had the same behavior as what I am trying to fix currently. The front panel would close, but the VI would somehow remain in memory. I saw that there were reference outlets on the property node and thought I could force the reference to close.
After looking through your code, I can't find how your Furnace Control VI stops automatically. The top while loop you have only stops on the value change of the VI STOP boolean and, after doing a Ctrl+F and searching for VI STOP, I didn't see how VI STOP is changed programmatically. If you are able to run this VI independently If you could point me to how your code finishes executing and is trying to close out currently, that might help me better understand the situation.
In the Acquisition event case, there is a case structure outside the while loop. The case is set to true from an subvi (which behaves as a state machine for the states of the acquisition process) inside the while loop. In the true case is a Value Signaling property node for the hidden Save Data button, leading to the Save Data event case. Once in this event case, the data is saved, and there is a Value Signaling property node for VI STOP button and event case. That is how the VI STOP event is triggered automatically.
If you were to switch that boolean attached to your VI STOP property node in your Save Data event structure from false to true, does that solve your issue? I ask because, if you did this then you should see identical behavior between pressing the stop button (which turns it true and signals the event) and the end of the experiment (which currently just signals the event). I don't see anything obvious that would be causing a discrepancy between these two cases but, by changing this boolean, it looks like you should receive the same expected (and desired) outcome whether your code is manually stopped or finishes automatically.