09-28-2009 04:50 AM
In the attached screenshot is my top level VI.
This starts by carrying out some initiallisation, then enters the main functional loop (which takes several seconds to run).
The code in this loop is prone to "hang", as it communicates with several DUTs whose firmware is still buggy.
I want to give this code a time limit to run, after which I know that something has gone wrong, and can take the necessary action.
I have done this by putting a time stamp in my local variable "tick value" at the start of each iteration.
My second loop, running in parallel, constantly monitors the difference between the current time and the value of the last time stamp sent by the main loop. If the difference is greater than my defined "timeout limit", then the second loop stops, and some other code runs.
As it stands, this 'other code' includes the "Stop" command. If I instead wanted to restart the VI, how should I go about doing this?
Thanks,
Dan
09-28-2009 06:12 AM
09-28-2009 06:20 AM
09-28-2009 06:31 AM
You can drop a Invoke Node (it is located in Application control on LV 7, don't know for newer versions). Then select Class (right click menu) VI Server -> VI. Then you can select the methodes Run and Abort.
As aborting the VI will not allow the restart, you will need a second vi that monitors the device vi. Use VI server to open a reference to the vi and wire the reference to the Invoke node, the class will automatically change to VI.
Felix
09-28-2009 06:40 AM
Make the code that "takes several seconds to run" into a sub-VI. See if this works and then we can work out a way to restart it.
09-28-2009 07:27 AM
Hi Jim,
My code now looks like the attached screenshot.
However, when it tries to abort the subVI "all tests.vi" using your suggested method, the attached error message occurs.
Dan
09-28-2009 07:39 AM - edited 09-28-2009 07:41 AM
My guess is that it's happening because the lower loop executed successfully and closed all tests.vi before the timeout occurred. The error is telling you that you can't abort a VI that isn't running. A quick fix would be to check the execution state of the VI and only abort it if it's running.
Do a test where you make the all tests.vi run past the timeout to see if the Abort method works for you.
09-28-2009 07:44 AM
No, I'm pretty sure that's not it.
I chose a deliberately short timeout value, so that it would not give "all tests" a chance to finish.
I will try your amendment anyway.
09-28-2009 07:58 AM
I just looked at this KB.
Even though the subVI that you called is running, it is not running under its own execution; it is part of the execution of the top-level VI.
The article tells how to launch all tests.vi with VI Server. Sorry for the mix-up.
09-28-2009 10:39 AM
My code now looks like this, but I now get the attached error message when I run it.
What am I doing wrong?