LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VIT used in subpanels vs reentrant VI

Hello,

I am working on a project where I need to open ten times the same vi onto the same windows (same vi) but into differents tabs. The ten vi openned and display msut be independant.

For this, I am currently using ten subpanels in which i am calling a template Vi (vit) in each.

 

It works in project mode and executable mode as well, so this is a good point  👍 (see picture attached).

But I want to be sure to use the best method:

  • I have checked around topics on the forum, vit sounds outdated and it is preferable to use reentrant vi instead , with asynchronous call.
    • Is it true ? If yes, why?
    • The fact is that I am not sure I can do this to open it ten times to place them in subpanels. I have tried to simply called them as a single reference, but it doesn't work (error message is display).
  • My project works well but the time to start it is quite long (about 10 secs. Well, it is OK but if I could avoid it, it would be better). This is because of the ten copy creation of template vi.
    Is there a way to reduce it ? 
  • I have hearded that If i do not close the ten template vi well, it will keep indefinitely (up to a PC restart) the RAM allocated. How to be sure I close them well ? 

 

0 Kudos
Message 1 of 7
(1,828 Views)

Almost a decade ago, I developed a routine to monitor animal behavior.  We had up to 24 "stations", each with an "activity sensor" and a video camera to record the behavior.  The Station was coded as a Reentrant Clone.  I "spun up" a Station, passing in identifiers for its Camera and Activity Sensor (so the Station could find and configure them itself).  Each Station had a "working Front Panel" that showed the Video from the Camera, and a Graph showing the Activity (a recording session lasted about 2 hours).  When the Station clone ran, its Front Panel showed only the Video and Graph (I used an OpenG function to size the Windows to the largest Decoration on the Front Panel, so I just placed a Frame decoration around the Video and Graph).

 

On the main Front Panel, I had a series of Booleans that selected the Station I wanted to view.  I used a sub-Panel on the main VI -- if I pushed the button for Station 4, the top level VI basically "turned off" the sub-Panel, then re-opened it, inserting Station 4 into the Front Panel.  [It really wasn't practical, for two hours, to look at all of the animals all at once].  Of course, you could program your task differently ...

 

However, I strongly recommend using sub-Panels rather than Tab controls.  If you can divide your Front Panel into "Controls/Indicators that are always present" and "Control/Indicators that vary with the situation", displaying the "visible" Front Panel of the VI placed in the sub-Panel.  [I learned about sub-Panels at NIWeek about 8-9 years ago, and find them very useful and easy to use.]

 

Bob Schor

0 Kudos
Message 2 of 7
(1,750 Views)

Have a look at this example. It is the strategy that I use for most of my projects that require dynamic FP controls.

Examples can be:

  • Showing different hardware configuration
  • Showing different measurement types
  • Showing different graphs. Subpanels are scalable, tab controls are not

This example starts all plugins in the background, stores their VI reference and inserts the selected one into the subpanel. Each VI runs independently.

Note that often you don't want to have all plugins running, just the one that is inserted in the subpanel. This requires some additional coding, but the strategy is the similar.

Basjong53_0-1667556491357.png

 

Message 3 of 7
(1,731 Views)

@Basjong53,

     I like your Demo.  Took me a while to recognize that "Generate" was a "Push me" control (it matched too closely the random number being returned).  It took me a while to figure out the reason for the Plugin Events Typedef -- it was to make the "User Events" in the Plugins have an "identifiable" name.  [I'd figured out the trick of naming whatever you wire into Create User Event"].

 

Bob Schor

0 Kudos
Message 4 of 7
(1,700 Views)

@TeraEngineer wrote:

Hello,

I am working on a project where I need to open ten times the same vi onto the same windows (same vi) but into differents tabs. The ten vi openned and display msut be independant.

For this, I am currently using ten subpanels in which i am calling a template Vi (vit) in each.

 

It works in project mode and executable mode as well, so this is a good point  👍 (see picture attached).

But I want to be sure to use the best method:

  • I have checked around topics on the forum, vit sounds outdated and it is preferable to use reentrant vi instead , with asynchronous call.
    • Is it true ? If yes, why?
    • The fact is that I am not sure I can do this to open it ten times to place them in subpanels. I have tried to simply called them as a single reference, but it doesn't work (error message is display).
  • My project works well but the time to start it is quite long (about 10 secs. Well, it is OK but if I could avoid it, it would be better). This is because of the ten copy creation of template vi.
    Is there a way to reduce it ? 
  • I have hearded that If i do not close the ten template vi well, it will keep indefinitely (up to a PC restart) the RAM allocated. How to be sure I close them well ? 

 


Your vit approach is obsolete.  Use an Asynchronous Call By Reference fire and forget instead.

 

Vits must create themselves as called and that takes a lot of time.   ACBR can create the entire Clone pool during launch with the preallocate Clone pool method.  This is a lot faster because only the dataspaces need to be created..  a vit creates the whole vi object..  Then each Clone is simply fired via ACBR and inserted into the subpanel.  The example finder has some nice projects demonstrating ACBR usage.

 

When you create references to multiple vis that are opened with the correct flags set each refnum is to a specific Clone instance.  The help file has a lot to say about how Clone pools work.  Spend some time digging.   I believe that an older post of mine summarizes most of it well.  Good luck digging it up. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(1,691 Views)

Hello,

Thanks for all your comments.

 

I have applied the asynchronous call. As a resultat, the time taken at the launch of the application has been greatly reduced.

 

Concerning the way to display the sub vi, I am not sure to understand well  what is the point: I guess I am undersanding it is a matter of what is executed at the background: more things with tab control (every indicators) are "executed" (but not displayed) versus the particular handling of subpannel which allows the application to handle only the indicators which are displayed. Am I correct ?

 

0 Kudos
Message 6 of 7
(1,649 Views)

@TeraEngineer wrote:

Concerning the way to display the sub vi, I am not sure to understand well  what is the point: I guess I am undersanding it is a matter of what is executed at the background: more things with tab control (every indicators) are "executed" (but not displayed) versus the particular handling of subpannel which allows the application to handle only the indicators which are displayed. Am I correct ?


I'm not sure you are "correct".  When you start running a sub-VI by using "Start Asychronous Call", it starts running, whether or not you are viewing its front Panel.  In many cases, sub-VIs don't have "interesting" Front Panels -- we generally only look at the Front Panel of "Main.vi", which has the "User Interface" with Controls to provide Input and Indicators to provide Output.  But with Sub-Panels and Asynchronous Calls, you can choose to display the Front Panel of a running sub-VI by displaying it in the sub-Panel.

 

I had an example where I was monitoring a dozen animals, each with their own Video Camera (using IMAQdx).  I created one sub-VI that would run the Camera and show a Video on its Front Panel. I made 12 re-entrant clones of this VI, then spun up 12 "Start Asyncrhonous Call" invocations, saving the sub-VI Reference.  My "Main" had a Control that I used to decide which Camera I wanted to view, which amounted to placing that Camera's Front Panel in the sub-Panel.  All the cameras were running in parallel, but I was only looking at them "one at a time" in the (shared) sub-Panel window (when I wanted to look at Camera 5, for example, I "closed the window" (this is old code -- I don't remember, off the top of my head, what the function was to remove a sub-VI from the sub-Panel) and then put in the sub-VI associated with Camera 5.

 

Note that I was only "viewing", and that the Cameras were all TCP/IP (not USB) cameras, operating at 10-30 FPS, 640 x 480, so there was no problem with "traffic".  Now, if I wanted to simultaneously save 10 Videos, that might present a problem ...

 

Bob Schor

0 Kudos
Message 7 of 7
(1,644 Views)