LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Abort Sub Vi from Main VI

Solved!
Go to solution

Suppose I have Main VI that calls Sub VI with some routine that usually takes very short time, but in some input conditions can run much longer. Suppose I want Main VI to be able to interrupt the execution of Sub VI and retrieve the interim result. I can add Abort button to Sub VI of course, but suppose I don't want to display the Sub VI's front panel, or... I just want Main VI to initiate the Sub VI abortion.

 

Ok, I figured out one way how to do it - my solution has 2 while loops and 2 global variables. It works, but isn't it cumbersome for such a simple task?

Please take a look at my example (increase number of points from 20 to 1000 to simulate longer processing). Is there some easier way?

0 Kudos
Message 1 of 12
(3,559 Views)
Solution
Accepted by topic author Arkady_V

Use synchronization object,

 

You have a nice portion of LabView to learn now, check the VIs.

If you have hard times understanding it, browse related sync objects examples...

 

Happy learning

 

Message 2 of 12
(3,530 Views)

Oh wow! I don't understand a bit of it right away, but your example behaves exactly the way I wanted my to - the one of mine still doesn't react to Stop button properly while SubVI isn't aborted. And all done with no globals.

 

Thank you, I have no other choice but accept it as a solution. Will try to understand these queues.

 

UPD: Ok, now I got it, and I must confirm that it's even not more complicated than my code, but has many potential advantages included: like now I possibly can, for example, retrieve the interim value without stopping SubVI, thing I even couldn't think about without using of global variables.

0 Kudos
Message 3 of 12
(3,524 Views)

The next level is to learn how to use actor framework.

0 Kudos
Message 4 of 12
(3,506 Views)

@Bublina wrote:

The next level is to learn how to use actor framework.


you should not stop a sub.vi using an "error"....use a notifier,reference, enqueue or variable...

0 Kudos
Message 5 of 12
(3,494 Views)

@apok wrote:

@Bublina wrote:

The next level is to learn how to use actor framework.


you should not stop a sub.vi using an "error"....use a notifier,reference, enqueue or variable...


Hi apok,

 

there is not error used to stop execution of a subVI,

 

maybe bother to explain why not,


why do you quote actor framework ?

0 Kudos
Message 6 of 12
(3,476 Views)

your second loop in the main is stopping on an error, thats what i meant.."Error 1 occurred at Dequeue Element in MainVi.vi", not a proper way of shutting down a VI

0 Kudos
Message 7 of 12
(3,465 Views)

I see what you mean, that an error is not handled properly...

 

Well, this happens when you want to show someone some basic architecture. If you take a look at what that example does, you can figure out it is whole entirely wrong, no doubt 🙂 it just happens to happen when you modify someones existing attachment.

0 Kudos
Message 8 of 12
(3,458 Views)

Sorry about that...Did not know it was inherent to the OP, my sincere apologies Smiley Embarassed

0 Kudos
Message 9 of 12
(3,452 Views)

@apok wrote:

Sorry about that...Did not know it was inherent to the OP, my sincere apologies Smiley Embarassed


You are so nice 🙂

0 Kudos
Message 10 of 12
(3,448 Views)