Jump to content

Calling the same VI as dynamic VI and as sub-VI


Recommended Posts

Hi folks,

I want to call a VI from the same main VI one time as a standard sub-VI, later as a dynamic VI. The 2 instances do not run at the same time, but consecutively.

The sub-VI call runs allright and so does the dynamic call, the VI works allright. Trouble starts, when I want to read an indicator of the dynamic instance, then I get an "invalid refnum" error. :blink:

If I use 2 identical copies of the sub-VI with different names, using one as sub-VI, the other as dynamic VI, everything is allright.

Is there something in LV that prevents me form doing such a thing or am I doing something wrong in the dynamic calling part?

I hate the thought of having 2 identical copies of a VI clogging up memory. :thumbdown:

Thanks a lot!

Guenther

Link to comment
I hate the thought of having 2 identical copies of a VI clogging up memory. :thumbdown:

I'm afraid you'll have. Keep in mind that the subVI is loaded in memory under your program, so when you try con control it programmatically, you are fighting against your own code. In my experience, when you call programmatically a VI you shouldn't have it as a subVI, even if that subVI is never called or is disabled.

My advice is to avoid that situation. If that's impossible, try calling it as a template (because each instance will have a different name and different memory allocation).

Hope that helps.

Saludos,

Aitor

Link to comment
In my experience, when you call programmatically a VI you shouldn't have it as a subVI, even if that subVI is never called or is disabled.

Is that true for a built application? I was under the impression that even dynamically called VIs had to be called as subVIs somewhere (like you said - in an area that is never called) in the built application. :unsure:

The way I get around this is to include a "tree" VI outside of the exe (but still part of the build) that includes all of the dynamically called VIs on it's BD - this means that if I need to update the system later and add new dynamically called VIs (ie: plugins), then I can overwrite the tree VI and include my new dynamically called VIs and they will load...

Link to comment
So, it doesn't look like there's an easy way out. Guess I'll have to live with the 2 copies.

Thanks for pointing that out, Aitor!

You're welcome. I don't know your application, but I'm pretty sure you could find a way of not having that VI as a subVI. For example, if you launch it through VI Server (i.e., dinamically) and check to true the "Wait until done" option, the program behavior will be almost the same as if it was a normal subVI.

Saludos,

Aitor

Link to comment

as far as i know, this will not work.

if you try to start a VI, which is NOT reentrant and which is a subvi of an other running vi, via VI server, you will get the error 1000: The VI is not in a state compatible with this operation.

Link to comment
  • 2 weeks later...
Is that true for a built application? I was under the impression that even dynamically called VIs had to be called as subVIs somewhere (like you said - in an area that is never called) in the built application. :unsure:

Why! Just make sure you add those dynamically called Vis as such to your build script or Project. Or as alternative if you do this for plugin VIs that should remain outside of the application make sure you compute the right path when trying to load it.

Of course there is the possible problem of plugin VIs using subVIs that were getting out of sync with the same named VIs used in the main application. This can be managed a little easier by using an All Project VIs.vi that contains all the dynamically called VIs as well as the main Top level VI. For editing the project you load this All VIs VI but you do not include that in the application build at all.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.