LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing Clones from Templates

Solved!
Go to solution

I am using a Template and VI Server to create multiple "clones" that allow me to run multiple tasks in parallel.  The Clones are written as a stand-alone VI, with a Stop button on the front panel that I programmatically push to stop the Clone.  If I create, for example, three clones, I will get three Front Panels Clone 1, Clone 2, and Clone 3.

 

When I go to close the Project, I get asked if I want to save the created Clones.  The answer, of course, is always "No".  Is there a way to programmatically "close" these Clones without saving them so I don't get asked this question?  I'm happy to have the Front Panels not be visible --indeed, my routine to start the Clone has a "Hide Front Panel" option, and my routine to stop the Clone has a "Close Front Panel" option -- if either is set, the Clone's Front Panel won't be visible when the program exits.  However, even in this case, closing the Project asks me to save all of the Clones.

 

One other question which may be related to the "unsaved Clones" -- when the program and Clones are stopped and I try to close the Project, I get a message saying "Closing the Project will abort some running VIs".  However, to the best of my knowledge, there are no running VIs.  Is there something I'm missing?  Can I "do something" to close/stop whatever is causing this message?

0 Kudos
Message 1 of 5
(4,760 Views)

Hi,

 

if you want to run several copies of an VI, you must use de reentrat execution property. All you have to do is marking your VIs as reentrant (File >> VI Properties >> Categoty: Execution). Every client computer will access to a different copy of the VI located on the server memory, so client computers can manage different data in spite of the fact that the server application is the same. You can watch this video for further information:

 

http://zone.ni.com/wv/app/doc/p/id/wv-106/nextonly/y 

 

maybe if you are creating those clones during the execution, when you close your template the programm ask you about saving the new VI´s created. There're some tools that can help you viewing the runnings VI as Tools->Profile->Performance where you can see the VI's in memory and their memory load.

 

i´m not sure i´m helping with your problem.

 

best regards!

 

saludos!

0 Kudos
Message 2 of 5
(4,743 Views)

Thank you for your comment.  However, clones created by using templates do not need to be reentrant -- each clone is a unique creation, and can be created with its own unique refnum, which can be used to individually stop each of them.  However, simply stopping them still seems to leave them in memory (hmm, this may be a "host" vs "remote" issue -- more experimentation is needed, I might be able to figure this out myself ...).

0 Kudos
Message 3 of 5
(4,725 Views)

Changing the VIs to be reentrant makes this much simpler - you simply wire 8 to the options flag for Open VI Reference and this dynamically creates a clone of the VI, which you can then run. Because this is a dynamic clone, it never needs to be saved.

 

As for VIs still running, make sure you properly stop the VIs (e.g. by sending them a stop command and having them stop themselves). Note that any reference based communication mechanism has the problem that the reference is automatically cleaned up when the hierarchy where the reference was originally created goes idle.


___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(4,721 Views)
Solution
Accepted by topic author Bob_Schor

I suppose there are "arguments" (or maybe even "evidence") over the best way to spawn asynchronous clones -- using a VI Template (as I did) and starting it using Run VI, making the VI Reentrant and starting it with Run VI, or using the Start Asynchronous Call.  I don't know the relative merits of these various methods, but conceptually (thinking in terms of "proving correctness", explaining to others, maintenance, etc.), the VI Template method doesn't seem "bad" to me.  Anyway, that was the premise of my question.

 

I do close all of the clones by "asking" them to stop themselves.  I have two chances to close their Front Panels -- I can choose to run them without opening the Front Panel, or can choose to close the Front Panel before stopping them.  Whether or not I do either (or both) of these, I was getting both a message saying I couldn't close the Project without stopping a running VI (but there was no VI "obviously" running) and asking me to Save all of the clones.

 

The correct answer to my question was to be sure that the references used to open and close the clones was closed, something I had forgotten to do (I discovered and fixed this omission today).  This seems to provide the answer to my question.

Message 5 of 5
(4,704 Views)