03-09-2013 11:11 PM - edited 03-09-2013 11:27 PM
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?
Solved! Go to Solution.
03-10-2013 06:42 AM
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
03-10-2013 06:59 AM - edited 03-10-2013 07:24 AM
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.
03-10-2013 10:16 AM
The next level is to learn how to use actor framework.
03-10-2013 02:42 PM - edited 03-10-2013 02:45 PM
@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...
03-10-2013 03:16 PM
@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 ?
03-10-2013 04:06 PM - edited 03-10-2013 04:09 PM
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
03-10-2013 04:12 PM
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.
03-10-2013 04:17 PM
Sorry about that...Did not know it was inherent to the OP, my sincere apologies
03-10-2013 04:20 PM
@apok wrote:
Sorry about that...Did not know it was inherent to the OP, my sincere apologies
You are so nice 🙂