03-17-2014 05:30 PM
Hi, All
I have a application need periodically check an instrument status and I put it in the "Timeout Event" in main vi. I also need call some subVis for configuration etc. Somehow when I called those subvi, the Timeout event in my main vi was not running. Then I use " Start Asynchronous Call" function to call the subVis. Turns out it works fine with some subvis without return value, but not as expected with "return value-needed" subvis.
I attached a simple test, my main vi call two dlg subvis: AboutDlg.vi and SettingsDlg.vi. In the timeout event, I just use a counter for simulation. When you run it, you can see the counter keep counting when the AboutDlg.vi was called, but stopped when SettingsDlg.vi was called.
As I remembered, someone suggested to use Queue to pass return value, but I don't know how to implement it here.
Anyone has any suggestions about it?
Thank you very much.
Solved! Go to Solution.
03-18-2014 07:44 AM
Try playing with this - I have modified your code to poke a Q in there.
You will want to change the clusters to more useful datatypes (maybe enum and variant so you can unbundle variants depending on enum input), you will want to type def the clusters to make it easier to maintain and you will NEED to handle the sitaution where the called VI is left open on program close - i couldn't be bothered as this was not your immediate issue)
Hope this give you some Ideas - totalyy untested but should work.
James
03-18-2014 12:54 PM
Thank you very much! it works
03-20-2014 01:02 PM
Here I added some code with checking the Dlg vi exec.state.
In "Stop" event, close the Refs of each Dlg.
03-21-2014 08:40 AM
03-21-2014 12:00 PM
Thanks, James
Will "Abort Vi" work? Here I check the Exec.state and use "Abort VI" to stop the Dlgs.
another question: which Labview tool helps to check the memory leak?
regards
CQ
03-24-2014 04:48 AM
Yes it will - this is the same as pressing the Abort button on the front panel so it is not a recommended technique as it could leave any H/W controlled by the VI in an undefined state and is not good programming practice.
(Personally I would use this only on VIs which have the state "Running" at the end of the main VI as a secondary stopping technique. the Primary technique I would use would be to set the value of a Control (Invoke node) for the VI and then name the control and pass in the value by variant. - This allows you to press the subVI STOP button from the calling VI!)
James
(You are doing very well so far picking up lots of complex architechtural stuff very quickly - it took me years to find all these techniques.)