LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop/abort a subvi called by reference ?

Solved!
Go to solution

Hi, I would like to simply abort subvis that I called by reference, I spent hours on the forum without finding anything. It seems simple thing but I can't do it XD

 

Please find attached the call by reference that I want to stop from the main vi.

 

Thanks!

 

Victor

0 Kudos
Message 1 of 13
(1,855 Views)

I don't think I've done this for almost a decade!  [I've used Start Asynchronous Calls all the time ...].

 

What you need to do is to get a "Stop" snuck into the sub-VI.  One way to do this is to create a Global Variable (call it "Global Stop").  Place it in your Asynchronous VI in such a way that when its value returns "True", your Sub-VI stops (I assume you are running something like a While Loop).  So all you need to do is to initialize the Global to False, start your code, and when you want to stop the Sub-VI, wire a True to the Global Stop.

 

Bob Schor

0 Kudos
Message 2 of 13
(1,821 Views)

 Hi Bob, thanks a lot for you answer!

 

I already tried to put a "Stop" in the sub-vi and pass a boolean to it as argument from the main vi. That's actually worked but it stops also the main vi, not only the subvi 😕 I know the "Stop" bloc is not really done for this kind of use so I guess it's a normal behavior, but I really can't figure out how to do this.

 

Victor

0 Kudos
Message 3 of 13
(1,811 Views)

Why do you want to abort it?  It's just as easy to stop it in a graceful manner.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 13
(1,803 Views)

Hi!

 

To be "clean", the main vi should be able to abort the sub vi if this last crashs for example. Sometimes the sub vi is calling an executable which can crash and after a timeout, the main vi should be able to close everything. 

0 Kudos
Message 5 of 13
(1,797 Views)

Add a User event input to the sub vi's. Then you can easily send them any type of command as they're running, including one to shut down.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 13
(1,787 Views)
Solution
Accepted by topic author ViGii

@ViGii wrote:

Hi, I would like to simply abort subvis that I called by reference, I spent hours on the forum without finding anything. It seems simple thing but I can't do it XD

 

Please find attached the call by reference that I want to stop from the main vi.

 

Thanks!

 

Victor


If you open the VI Ref with option 100 hex, and instead of Call By Reference, use Start Asynchronous Call and Wait On Asynchronous Call then you can just the the Abort method.

cbr2.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 13
(1,782 Views)

Ahah I exactly did that this morning ! It's working but still an issue... It's not working after builing an executable, I'm currently investigating why 😅

 

Thank you a lot for you help Paul, I should have asked for help before 🙂

 

0 Kudos
Message 8 of 13
(1,778 Views)

When I am putting together a test sequencer or a simple fault finding front end I normally have something like a functional global called "Stop" which I can set to "True" when the operator hits the "Stop" or "Abort" button on the main front panel.

 

In all the sub VIs I call that take longer that a few seconds to run I add the "Stop" global in various places, such as the terminator of loops etc. Sometimes an abort is too brutal, for instance you may want to ensure power supplies are reset or the unit is put back into a safe mode.

 

Once you get back to an idle state then you can clear the "Stop" flag.

 

Especially when fault finding problematic boards, there are lots of times when you want to abort a long measurement or sequence of measurements.

0 Kudos
Message 9 of 13
(1,744 Views)

I managed to get the executable working with the Paul's solution but only if I'm going to Property and check the Use Labview 8.x file structure... Do not know why but that's another subject.

0 Kudos
Message 10 of 13
(1,715 Views)