Jump to content

Problems closing a dynamically called vi


Cat

Recommended Posts

I have a main program that calls a lot of subvis dynamically. When the user selects a particular function, I open a reference for the corresponding vi and run the vi. When the user exits the vi, I close the front panel and close the reference.

This works fine, except... I have a vi I call "Big Top.vi" that doesn't do anything but hold all those dynamically called vis on its BD, basically for debugging and organizing (this was originally developed in the pre-LVproject days). If I have Big Top open (not running, of course), and I call a vi dynamically with the main program, after the dynamically called vi exits and the reference is closed, the vi is still running. I can't see it (the front panel is closed), but if I open Error List, that vi is in there as "already running". Even after the main program is exited, the dynamically called vi is still running. I've checked, and the reference is indeed closed when it's supposed to be.

This isn't a huge deal, since the code will be really run as an executable. And now that I know what's causing the problem I'll just manually clean everything up when I'm working with the source code, or not open Big Top in the first place.

But my question is what's going on?? I'm assuming it has this issue because the vis aren't normally in memory when they're called, but when Big Top is open they are in memory since they're parked on the BD. But I don't get how this keeps the called vi running even after its reference has been closed. Or is there some other step for *really* closing the vi that I'm missing?

Cat

Link to comment

QUOTE (Cat @ Mar 20 2009, 08:46 AM)

I have a main program that calls a lot of subvis dynamically. When the user selects a particular function, I open a reference for the corresponding vi and run the vi. When the user exits the vi, I close the front panel and close the reference.

This works fine, except... I have a vi I call "Big Top.vi" that doesn't do anything but hold all those dynamically called vis on its BD, basically for debugging and organizing (this was originally developed in the pre-LVproject days). If I have Big Top open (not running, of course), and I call a vi dynamically with the main program, after the dynamically called vi exits and the reference is closed, the vi is still running. I can't see it (the front panel is closed), but if I open Error List, that vi is in there as "already running". Even after the main program is exited, the dynamically called vi is still running. I've checked, and the reference is indeed closed when it's supposed to be.

This isn't a huge deal, since the code will be really run as an executable. And now that I know what's causing the problem I'll just manually clean everything up when I'm working with the source code, or not open Big Top in the first place.

But my question is what's going on?? I'm assuming it has this issue because the vis aren't normally in memory when they're called, but when Big Top is open they are in memory since they're parked on the BD. But I don't get how this keeps the called vi running even after its reference has been closed. Or is there some other step for *really* closing the vi that I'm missing?

Cat

If the dynamic open a ref to itself, it can keep itself open.

Ben

Link to comment

QUOTE (neBulus @ Mar 20 2009, 09:51 AM)

If the dynamic open a ref to itself, it can keep itself open.

I looked all over for other calls before I realized the problem only happened when Big Top was loaded. So no, I don't think it's calling itself.

Link to comment

The rule is that a VI will be unloaded from memory when its front panel is not visible and no references to it are open.

When you run your code WITHOUT the Big Top open and the VI that opened the dynamic VI closes its reference, there is no longer any references to the dynamic VI, so LabVIEW unloads the VI from memery (essentially aborting it)

When you run your code WITH Big Top open and the VI that opened the dynamic VI closes its reference, there is still a reference to the dynamic VI on Big Top's block diagram, therefore the dynamic VI continues executing.

What I usually do, is launch the dynamic VI, and provide a way to command the dynamic VI to stop (VI Server, Queues, etc). The dynamic VI can then perform any clean up and stop gracefully. This would allow you code to function properly regardless of Big Top

Hope this helps

Link to comment

QUOTE (djolivet @ Mar 20 2009, 10:35 AM)

The rule is that a VI will be unloaded from memory when its front panel is not visible and no references to it are open.

When you run your code WITHOUT the Big Top open and the VI that opened the dynamic VI closes its reference, there is no longer any references to the dynamic VI, so LabVIEW unloads the VI from memery (essentially aborting it)

When you run your code WITH Big Top open and the VI that opened the dynamic VI closes its reference, there is still a reference to the dynamic VI on Big Top's block diagram, therefore the dynamic VI continues executing.

Now I'm really confused. :wacko:

Maybe the problem is semantics, and I don't understand what you mean by "there is still a reference to the dynamic VI on Big Top's block diagram". Do you mean that just having the icon for the vi on the BD (that never gets run) creates a reference to that vi (as opposed to loading it into memory), and that's the one that's not getting closed??

After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill.

Link to comment

QUOTE (Cat @ Mar 20 2009, 09:06 AM)

Now I'm really confused. :wacko:

Maybe the problem is semantics, and I don't understand what you mean by "there is still a reference to the dynamic VI on Big Top's block diagram". Do you mean that just having the icon for the vi on the BD (that never gets run) creates a reference to that vi (as opposed to loading it into memory), and that's the one that's not getting closed??

After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill.

Closing the front panel won't stop a VI that's been loaded dynamically - you can close and then re-open the panel and the VI will still be running. Closing all refs will. As long as the VI is running some sort of blocking process (loop, wait to dequeue, something) and there's a ref around, it will continue to run. Sounds like your VI panel gets closed but it never actually stops except when all refs go dead, so you may want to look at how you command the VI to actually stop.

Mark

Link to comment

QUOTE (Cat @ Mar 20 2009, 10:06 AM)

Yes

QUOTE (Cat @ Mar 20 2009, 10:06 AM)

After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill.

Just because you close the panel of a VI doesn't mean it stops running (as you are seeing).

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.