LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubPanel VI not closing correctly

Solved!
Go to solution

I'm using a subpanel in my program which opens in the consumer loop. when the program is stopped the reference to the VI in the subpanel is closed, however when i then go to open the vi which I run in the subPanel I can't open it as it is still in memory or something. this mean i have to close all of labview down just to switch VI's. Does anyone know why my subpanel VI isn't closing correctly? 

 

Labview 14.0

 

Thanks

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 1 of 14
(8,264 Views)

Anyone?

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 2 of 14
(8,243 Views)

Closing the reference to the VI in the subpanel is not enough. You need to tell the VI to stop executing. Typically for this I would use a user event/queue and pass the reference into the VI but you could also have a 'shutdown?' FGV.

 

Edit: Also, your Variant 1, 2, 3 etc. is surplus to requirements. You could have a single 'data' variant and give it a cluster containing the 3 different elements which you then convert using variant to data in the 'process video and data' case of your state machine.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 14
(8,242 Views)

Okay thats sounds great, just to clarify what you mean however as I'm reasonably new to labview. I've now put a stop function in my lower level VI which is in the sub panel so that when i hit 'stop application' it stops the program running. This works, however ideally i would like to stop it also when i press the stop button on the top level VI. Do I do this by passing an input in the to the start asychronous call function which could be a boolean and would then make a 'stop app' case in the subpanel VI. Or does the inputs to the subpanel only get passed once?

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 4 of 14
(8,228 Views)
To stop the dynamically launched VI you need some sort of signalling to tell it to stop. The way I like to do it is to create a user-defined event or UDE that will stop everything when it fires. Here is a post that talks about a nicely encapsulated approach.

http://www.notatamelion.com/2014/10/23/making-udes-easy/

For this technique to work you will need to build your application using event-driven techniques -- other posts on the same site talk about that if you are not familiar with it.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 14
(8,219 Views)

Hi, thanks for replying! I just read most of the post and I don't see how that is relevant to the issue i have. Forive me if it's obvious. All i need to do is pass a stop boolean to a subpanel VI which will then use that in an event driven state machine to stop the VI running. How does what you link solve that, also I can't afford to be changing the whole artitecture of my VI.

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 6 of 14
(8,211 Views)

Your top-level VI needs to tell the dynamically launched VI to 'stop'. This is the same as telling other loops to stop in any multi-loop architecture - you need to communicate that information between loops/VIs.

 

I normally use user events. I create a user event in the top-level VI for a 'stop' event and then wire the reference into the dynamically called SubVI. When I want to stop the SubVI, I generate the 'stop' event on the top-level VI (e.g. in the 'exit' case).

 

From the sounds of it, your SubVI already has an event structure, so just use the 'register for user event', wire the reference to it and then create a case in your event structure to 'stop' the SubVI.

 

That is just one method, you could also use other methods (e.g. Queues, Globals, FGVs etc.)


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 14
(8,204 Views)

How do I go about wiring the user defined event into the SubPanel VI. And then once I do that how do i then get the lower level program to run the desired case. My lower level VI is user event driven but this wouldn't be a user event as I would be passing it a boolean, wouldn't I?. The user event is in the top level. I'm rather confuised but I feel that this is something obvious that I'm not getting. 

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 8 of 14
(8,195 Views)

Have you tried looking at the help/examples on user events? http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/creating_user_events/

 

You can't just pass in the boolean from the top-level VI because its value only gets read once when it gets passed in when you launch your SubVI with the asynchronous call by reference node.

 

What you will end up doing is modifying the connector pane of your SubVI to add the user event reference so you can pass it in from your top-level VI.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 14
(8,187 Views)

But I would need to wire the reference to the subVI before I create the reference to stop the VI wouldn't I? 

 

For example I call the asychronouse VI into the subpanel with various input that it will read once that case run. Later I want to stop so I create the reference to the stop in the producer and pass to the consumer which stops high level VI but then I can't pass the reference to the low level as I already passed the inputs before and so it would not read them. 

 

 

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 10 of 14
(8,149 Views)