LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open/run Multiple Windows of the same VI

Solved!
Go to solution

Hi!

 

In my current project I would like to have the user open multiple windows of the same VI.  I've made a re-entrant VI:

Re-Entrant Dialog Box.png

 

This is, currently, a very simple VI that just has a numeric control, a loop, and a stop button.  I then have a VI that calls the re-entrant VI.  I'd like it so that each time the user presses the "Call Re-Entrant VI" button, a new window of this VI is spawned and run.

 

Call Re-Entrant block.png

 

The first time the button is pressed, the re-entrant VI opens and runs fine. The title of the VI in the title bar is "Re-Entrant.vi:1 (clone)" (as expected).  When I try to launch another instance I get this error:

 

Error Dialog Box.png

 

I'm running LabVIEW 2009.

 

Thanks for your time.

0 Kudos
Message 1 of 20
(5,792 Views)
Solution
Accepted by topic author hecmar.arreola

I think you can't do this with a static VI reference, because this always points to the same instance of the (reentrant) VI.

You need to open a new instance using Open VI Reference with the 0x08 option (prepare for reentrant run).

 

Hope this helps,

Daniel

 

Message 2 of 20
(5,787 Views)

That worked as far as getting multiple windows open.  However, the VI instances don't run.  Even if I enable the option "Run when openned" in the VI Properties under Execution, they don't run when called.

 

My preference is to not use the Open VI Reference VI to create a reference.  If it is the only way, then I will have to.  I like the static VI reference because I like the extra layer of pre-run error checking LabVIEW provides me when I use static VI references.  If I change the name of the VI all the static VI references are automatically changed.  I also do not have to worry about where the VI is in the directory structure during development, or after I have built my project into an executable.  I also think it makes the block diagram easier to read.

 

Thanks for your help!

0 Kudos
Message 3 of 20
(5,781 Views)

Probably you can use a static VI reference, then use a property node to get the VI name, then wire the VI name to "Open VI Reference". I think you have to use the "Open VI Reference" function to open multiple instances of a reentrant VI.

 

What error do you get when you try to run the several instances?

 

Message Edited by dan_u on 10-08-2009 06:06 PM
Message 4 of 20
(5,776 Views)

I can run them by pressing the "Run" button.  They just don't run when I call them.  The "Run" command I'm sending in the invoke node is not starting them.  And the option "Run when openned" is not working either.

 

There is a link to an example under the 0x08 in the "Open VI Reference" VI help, but it isn't openning anything on my machine.

 

Thanks for the idea on using the static VI reference.  I ended up going with the "Path" property and fed that into the "Open VI Reference" VI.  

0 Kudos
Message 5 of 20
(5,766 Views)

If I enable "Wait for done" in the Run Invoke node, the VI clone opens in a "run" state.  However, my calling VI is now hung-up waiting for the VI to stop.

 

Hmmm....

0 Kudos
Message 6 of 20
(5,762 Views)

Here we go.  The Close Reference VI was causing my re-entrant VI to stop execution.  What do you think of this:

Call Re-Entrant VI Snippet3.png

 

This appears to work.  I'd probably want to get the path of my referenced re-entrant VI outside of my loop (since this will remain constant throughout the programs execution).  My guess is the Auto Dispose Ref feature will mean that as these windows are closed by my user, their garbage will be collected properly....?

 

Thanks for your help.

 

Edit: how odd that my Error Cluster constant in the VI Snippet wasn't saved to the image properly.

Message Edited by Nickerbocker on 10-08-2009 10:33 AM
0 Kudos
Message 7 of 20
(5,749 Views)
I can't edit my re-entrant VI if I run my code.  Even if I close the "Call Re-Entrant.vi" and open the Re-Entrant.vi directly it won't let me make any changes.  The only way I can is if I completely exit out of LabVIEW and open this Re-Entrant.vi before running my code.  Operate->"Change to Edit Mode" is greyed out.  Any ideas?
0 Kudos
Message 8 of 20
(5,717 Views)

The issue has to do with the references to the VIs not being closed properly.  The "Auto Dispose Ref" did not seem to be doing what I had thought it was doing and these references were left in memory limbo.  That was why LabVIEW would not let me make modifications to the Re-Entrant.vi after running my code.  So now the problem is, if I close the reference after openning it the VI doesn't run.  I have made the following modification but dislike my method because I have to pass my array of references through each event in my event node.  Probably be better with a queue or maybe there is an entirely different approach I should be doing all together.

 

Closing the references.png

Message 9 of 20
(5,712 Views)

Thanks for the update. I think the VI references are not disposed when the SubVI has finished, but I would expect them to be disposed when the caller terminates. Doesn't seem to be the case.

Thanks for sharing, the code looks good and I like the approach with getting the VI path from the static VI reference.

 

0 Kudos
Message 10 of 20
(5,706 Views)