07-26-2016 05:23 AM - edited 07-26-2016 05:25 AM
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
Solved! Go to Solution.
07-26-2016 06:26 AM
Anyone?
07-26-2016 06:28 AM - edited 07-26-2016 06:32 AM
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.
07-26-2016 07:13 AM
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?
07-26-2016 07:43 AM
07-26-2016 08:52 AM
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.
07-26-2016 09:02 AM - edited 07-26-2016 09:04 AM
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.)
07-26-2016 09:24 AM
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.
07-26-2016 10:18 AM
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.
07-28-2016 05:37 AM
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.