LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening multiple instances of the same vi

Hi,
I am having trouble opening multiple instances of the same vi.
This vi that I am trying to create can be used like a message display window to display numbers, strings etc (just like labVIEW's display message control except that this vi will update the displayed controls every scan). So for example, I will like to have a subvi, lets call it popup.vi, where I wire in three inputs from my main vi (2 strings and 1 number). Now in my main.vi I have 2 numeric controls Num1 and Num2 with their KeyFocus property nodes.
The intention is that when I select Num1 or Num2 numeric control with my mouse the KeyFocus boolean becomes true and the popup.vi logic kicks in. Meaning that the popup.vi runs and opens its front pane
l displaying the two strings and one numeric value from the main.vi.
The problem arises when I want to open and run multiple instances of the popup.vi.
So when I click on Num1 with my mouse I want the popup.vi to open its front panel with a set of strings and number displayed. At the same time I would want to click on Num2 control and open another instance of the popup.vi with another set of strings and numeric value.

Also, I saved the popup.vi as popup.vit but for some reason vi server will not open the popup.vit. I get a message that popup.vit is already in memory - cannot load.
I have attached a sample of the main.vi and popup.vi program.
Please let me know if you need further clarifications.
I appreciate your help in this matter.

Thanks
Nish
0 Kudos
Message 1 of 6
(3,867 Views)
You have to clone the VI. You say you have tried to use the .vit way of cloning...but in the example there is no use of VIT and the VI is called statically. If you want to open multiple instances of the same VI and the VI has a user interface (or needs to be a unique instance of the VI every time even though it's called the same place in the diagram, not the case here though) you need to do it dynamically, i.e. with an invoke node.

There is actually a problem doing just that, it causes a memory leak...but that won't be a problem unless the VI is called frequently / the software will be running over very long periods of time. You can see an example of it here (attached to my reply to the question):

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&
RPAGEID=135&HOID=506500000008000000A07D0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=VI+cloning&USEARCHCONTEXT_QUESTION_S=0

About the memory leak problem:
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000B7A40000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=VI+cloning&USEARCHCONTEXT_QUESTION_S=0
Message 2 of 6
(3,867 Views)
Giving inputs to cloned VIs can be done using the set control value method, just do it with the same invoke node as you use when you call the VI e.g.....however that method is not supported in built applications (!), so if you are going to build an application of your code you need to make a functional global that holds the data for the just called clone...and then the clone calls the global VI with e.g. it's name as input and the VI finds the inputs for that clone.
0 Kudos
Message 3 of 6
(3,867 Views)
Mads,
Thanks for your suggestions. My plan is to create an executable for my application so I guess I will have to clone my popup.vi program and pass the control values to the cloned popup.vi via functional globals.
The only one concern I have is that there can be hundreds of clones created at the end of our test day.
Is there a way to clone the vi and keep it in memory instead of creating a hard copy on the disk?
Thanks for your help.
Regards,
Nish
0 Kudos
Message 4 of 6
(3,867 Views)
If you use a .vit and just open references to it you get unique instances of it, you can read the name property right away and use that to place the input for it in the functional global. The clone will only exist in memory and will be destroyed as soon as it has been closed and there are no references to it (when you run it using the invoke node just set auto dispose reference to True).

If you use file copying the clone can run a delete of it's file right away, it's only there for the call - after that it's in memory.
0 Kudos
Message 5 of 6
(3,867 Views)
The only limit for amount of opening clone instances is memory limit.
In my opinion the best way to pass prameters to numerous clones of VI is
using notifiers and queues.
You can use named notifies or pass the notifier reference via VI server (set
control value) to the next clone (before using invoke node with RUN VI
method).
I've done application with possibility runing numerous clones of the same VI
using VI template.
It works as a build application, as well.

Gregor-SPRINTER

Uzytkownik "nash" napisal w wiadomosci
news:506500000005000000152D0100-1042324653000@exchange.ni.com...
> Mads,
> Thanks for your suggestions. My plan is to create an executable for
> my application so I guess I will have to clone my popup.vi program
and
> pass the control values to the cloned popup.vi via functional globals.
> The only one concern I have is that there can be hundreds of clones
> created at the end of our test day.
> Is there a way to clone the vi and keep it in memory instead of
> creating a hard copy on the disk?
> Thanks for your help.
> Regards,
> Nish
0 Kudos
Message 6 of 6
(3,867 Views)