LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem to open and abort a subvi by invoke node

Solved!
Go to solution

Hello,

I have a subvi that is runing in a while loop and it is doing calculation that finish in a variable time. So I decided to add the abort function in invoke node. It is working perfectly when the subvi is running by its own but gives an error.

Error 1000 occurred at Open VI Reference
Possible Reason(s): LabVIEW: The VI is not in a state compatible with this operation.

I found that there is a solution for that in the follwing link.

http://digital.ni.com/public.nsf/allkb/790AC75B07D971ED86256C53007BDCE9

So I added the Run Vi invoke node in the main vi and abort VI invoke node in the subvi

as in the following snippet but I still get the same error. What do you think I am missing?

s1.png

s2.png

0 Kudos
Message 1 of 10
(5,072 Views)

It's hard to tell from your post.  I have no idea if you're using things in parallel or if you're running this abort in a way that ensures it can only run after the subVI is finished.

 

Really, it looks like you're complicating things that can be handled much simpler.  What triggers the need to abort the subVI?  If we understand that, we can likely give you better advice.

Message 2 of 10
(5,054 Views)

The problem is that the subvi can take ages to finish and I would like to abort it if the run of the subi takes more that a certain time, so another iteration of the loop can start.

Cheers,

Zied

0 Kudos
Message 3 of 10
(5,048 Views)

You didn't really answer ayn of my questions.  Without knowing the answer to those, it's near impossible to help you.

 

Are you running the processes in parallel?  If not, you can't click on anything to abort the subVI.  Dataflow will require you wait. 

 

What causes this variation?  It sounds like THIS is far more important to understand than how to abort the subVI.  If you abort it, you're putting yourself into an awkward state and all because you didn't want to wait.  It'd be better to add something into the subVI to control how long it takes.  If it takes longer than 10s (as an example), it errors out and passes the error up.  As it stands, you have no idea where it's at in the subVI that's making it take longer.  You might abort it at a very bad time.

Message 4 of 10
(5,045 Views)

In order to use the Run VI Method and Abort Method the VI cannot be called as a SubVI.  If the VI is in a state reserved to run than those methods will result in Error 1000.  This means that the VI cannot be in the VI Calling Hierarchy of your main VI (directly on your block diagram of the main VI or other SubVIs).

 

If the VI needs to be abortable, then you probably need to look into running that VI asynchronously and/or using a better architecture.  If that is the case I would look into stopping the loop by using a Notifier or Queue.  

 

As has been said before (not sure by whom), "Stopping a VI with Abort is like stopping a car with a tree.  It gets the job done but you might not like the results."

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 5 of 10
(5,031 Views)

The example in this link can help you to get started for stop SubVI's execution from main VI:

http://digital.ni.com/public.nsf/allkb/E38991F4A3892B6F86256E44004C5963

-If it doesn't help please attach sample of your subVI and Main VI both and see what can be wrong.

Thanks
uday
Message 6 of 10
(5,009 Views)

Thank you guys,

You are right, I think things are getting more and more complicated.

I put attached the subvi that is running in a loop from the main VI( sorry I cannot put the main VI as it contains confidential parts).

x0,y0,z0 change in each iteration of the while loop of the main vi. I kept the conditions where the simulation loop takes too long to finish. And to ansewer your question, this simulation loop that triggers the need to abort the subvi after let's say 10s.

If I can understand why the simulation stuck under certain combinations of x0,y0,z0 and find a solution for , it will be even better.

Cheers,

Zied

0 Kudos
Message 7 of 10
(4,993 Views)

I'll look at that in a bit.  I did want to post something that just caught my eye looking more closely at your code.

 

Why do you have a sequence structure in the first snippet?  It's entirely useless.  With dataflow, a node won't run until it gets all of its inputs and won't make any outputs available until it finishes. If you remove the sequence structure from the first snippet, everything will execute in the same order it does now.

Message 8 of 10
(4,968 Views)

As you said it is useless, I forgot to delete it.

I removed it now but this did not solve the problem.

I still belive that the simulatin loop in the subvi is the cause of the problem and if I can control the time limit of its execution, my problem will be solved. I wish it has the stop bottom like in while loop.

 

0 Kudos
Message 9 of 10
(4,961 Views)
Solution
Accepted by topic author ziedhosni

Eureka. I found it.

It was very simple.

Just I add the Halt simulation in the simulation loop if the time exceeds certain limit.

Anyway, thank you guys for helping me.

Cheers,

Zied

0 Kudos
Message 10 of 10
(4,960 Views)