LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple panels of the same vi

I want to run a VI multiple times at the same time (in parallel).
That works in principle (dynamicaly load and run it in reentrant mode).
But I never get multiple copies of the frontpanel of that VI.

I tried several things, but I saw only one frontpanel of all the instances I started.

How can I do that ??
0 Kudos
Message 1 of 10
(3,837 Views)
To dynamically create VIs with front panels you need to clone the VI. VI cloning can be done in many different ways, but if you want to build an executable of the code the attached example works very nicely.

Just unzip the archive as it is and open and run main.vi in the llb file, then hit the new graph button to create clones of a VI displaying a graph of data controlled from main.vi.

In this case I clone the VI by making copies of a VI that is included together with the llb/executable (when distributed I normally remove the diagramme of the VI), and I share data using a VI global.

Another approach is to call a VI template instead of copying, and set the start value of the controls using VI server functionality, you can probably find more info about
that if you search for VI cloning or cloning front panels.

VI cloning is very useful even if the VI is not going to show a front panel; if you make a client-server solution and want each client session to be handled in parallel make a session handler, clone it for each connection and pass the connection handle to the clones by putting them in a list together with the name of the clone to handle that connection...The clone searches through the list, finds the connection and starts handling the commands from the client.
Message 2 of 10
(3,837 Views)
Hiya

You cant show the front panel of a reentrant VI when called programmatically. If you want to show the front panels popup you will need to make multiple copies of the same VI and call them different names (eg. example1.vi, example2.vi, etc). You will then be able to write a VI server function to call the next available example vi or simply drop in the new subVI's in independent loops into the diagram.

However, if you do not know the maximum multiple of VI's you will ever want opened at one time this will be tricky as you wont know how many copies of the example vi to save. It can also be very monotonous to save multiple copies of the same VI. Unfortunately i dont think there is another way.

I hope this helps - let me know if you have any proble
ms.

Kim
0 Kudos
Message 3 of 10
(3,837 Views)
Actually, the cloning idea is very good...not come across it before! I'd go with this one.
0 Kudos
Message 4 of 10
(3,837 Views)
Is it not possible to automatically create the cloned VIs (example1, Example2,.... Examplen) using the VI server? Open a refernce to the desired VI, connect to a method node and choose "Save VI". Here you can give in the name (indexing up to n examples) and save the extra versions in a temporary directory.

I think I did this once with success, but perhaps it only works in development mode.

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 10
(3,837 Views)
That is the most elegant way yes - it has been used in examples made by NI and presented in LTR, but as you mention the necessary VI server commands does not seem to be supported in built applications.
0 Kudos
Message 6 of 10
(3,837 Views)
Save VI method is not available for built exec but cloning can be done.
You can distribute the VI as a separate file and copy the VI when needed and open the copy. Or use the *.vit extension for the VI. A new instance of the VIT is created in memory when opening a reference to it.


LabVIEW, C'est LabVIEW

0 Kudos
Message 7 of 10
(3,837 Views)
Copying is what I used in the example posted earlier.

I use file copying instead of VITs to avoid getting the save dialogue from all the clones when they are closed when run during development.
0 Kudos
Message 8 of 10
(3,837 Views)
> I use file copying instead of VITs to avoid getting the save dialogue
> from all the clones when they are closed when run during development.

If they are closed programmatically, while still running, there will be
no save dialog.

Greg McKaskle
0 Kudos
Message 9 of 10
(3,837 Views)
Thanks for sharing the cloning example. Is it possible to post a small example for the cloning of client-server solution that you mentioned above?

Thanks again
0 Kudos
Message 10 of 10
(3,837 Views)