LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restarting a VI

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

Dan
CLD
0 Kudos
Message 1 of 19
(5,129 Views)

Have you tried the Abort method?

abort.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 19
(5,098 Views)
Can you explain how I'd do this - I'm fairly new to LV.
Dan
CLD
0 Kudos
Message 3 of 19
(5,090 Views)

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 

Message 4 of 19
(5,080 Views)

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.

 

abort.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 19
(5,073 Views)

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

Dan
CLD
Download All
0 Kudos
Message 6 of 19
(5,049 Views)

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.

 

abort.png

 

 

Do a test where you make the all tests.vi run past the timeout to see if the Abort method works for you.

Message Edited by jcarmody on 09-28-2009 07:41 AM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 19
(5,030 Views)

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.

Dan
CLD
0 Kudos
Message 8 of 19
(5,025 Views)

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.

 

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 9 of 19
(5,016 Views)

My code now looks like this, but I now get the attached error message when I run it.

 

What am I doing wrong?

Dan
CLD
Download All
0 Kudos
Message 10 of 19
(4,964 Views)