LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple instances of a single VI

I would like to programmatically start a VI multiple times.  But I don't know how many times.  I know that the VI needs to be reentrant and I should probably start each instance with the Start Asynchronous Call function.  However the user needs to start each instance of the VI and should be able to quit a specific instance.  To keep track of all the instances of the VI, I'm sure I will need a cluster functional global variable.  I want the Start Asynchronous Call function to be called within an Event Structure since each instance is user generated.  But I can't seem to set the options input of the Open VI Reference function correctly.  The options I think I need are 0x08, 0x40, and 0x80.  Also, the front panel of each instance need to be opened when the VI is called so that the user can interact with it.

0 Kudos
Message 1 of 3
(3,706 Views)

Hello,

 

Use option 8 in the Open VI reference function to make the VI reentrant.

 

Use the "Run VI" method to launch the VI when it is called.

 

"Open VI" and "Run VI" will be the code contained in your event structure, to open and run instances of the VI.

 

Inside your VI, use the "FP.Open" method to open the front panel when the VI is launched.

 

Track the references however you choose, I like to use an array.  Element 0 is the first instance opened, element 1 is the second instance opened, etc.  There may be better ways to do that.

 

Hope that helps a little, or at least points you in a direction!

0 Kudos
Message 2 of 3
(3,696 Views)

just answered a similar case and had this link still copied 🙂 . Take a look at this example. Using a VIT should give that functionality, since you want to use the front panel of that VIT interactively I guess.

 

http://forums.ni.com/t5/LabVIEW/front-panel-state-of-VI-in-subpanel/m-p/1697738#M601499

 

But instead creating all the VI's before the event structure, you can put the create code that creates a single element inside an event structure. if your not using the sub-panel, you must ofcourse open the frontpanel of the VIT when running.

0 Kudos
Message 3 of 3
(3,678 Views)