LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to "break" an event structute?

What I have is an event structure with 2 cases, within a while loop. Case 0 is triggered by button and contains a very very long sequence and the other (case 1) I put it just to have an stop button and then stop the while loop with its value.

What I need its to be able to stop the execution of case 0 at any time while the sequence is running and stop the while loop right away (I need to let the vi finish, I dont want to abort it). Besides if the VI is waiting for an event and the abort button in case 1 is hit the VI should also finish (this is working fine). I want to do these 2 actions with one single "abort" button

The attached VI ilustrates the problem

(My problem has nothing to do with front panel bloking)
0 Kudos
Message 1 of 6
(2,908 Views)
I am sorry but I cannot open your VI so I'm going to take a guess here. If you are using a sequence structure you cannot break this until it finishes. Post your code in version 7.0 by going to file/save with options/save for previous and I will have a look at your code and tell you exactly what you are doing wrong.

Joe



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 2 of 6
(2,908 Views)
you can use a local variable connected to a button in your while loop.
or if you call one or more subvi's you can use a reference to a button on the main-frontpanel in the loop you most often called.
if you are using a sequence-frame you may break it down in subvi's and chain them by using error in - error out

i changed your vi to illustrate local variable and reference
0 Kudos
Message 3 of 6
(2,908 Views)
Hi, here is the file for LV7.0. I have sequence structures in some subVIs that are part of my sequence but not in the final sequence (this is not shown in the example), Thanks!
0 Kudos
Message 4 of 6
(2,908 Views)
Thank you very much... with your solution a part of the problem is solved, but I still have some issues with the event. The while loop I used was just for the example, in my real application the while will be a big chain of sub VIs (with no loop), I just put the loop as a time consuming task. So, if I move the modifications you made out of the loop, it doesn't work...

Regards
0 Kudos
Message 5 of 6
(2,908 Views)
It is very common that people want a sequence that can be stopped or redirected depending on user inputs or return values from functions and sub VIs.

That's why you have the State Machine structure. Take a look at the already made template in "New� >> VI From Template >> Frameworks >> Design Patterns >> Standard State Machine".


This programming structure is extremely flexible and expandable. It basically performs a sequence, depending on the return values from each step. This means that you can go to a certain �shutdown� state if you receive an error, or if the customer chooses to stop, or you can simply stop the loop without a state.

I would recommend you to read the online State Machine tutorial, for you to evaluate how useful it would be to implement it in your application.


Have fun!


Best regards,
Philip C.
Applications Engineer
National Instruments
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 6 of 6
(2,908 Views)