How to stop While Loop in Event Structure with same button?

I have a problem. I want to use one control to activate an event in a event structure, and the same control to terminate a while loop in that event.
It is possible to use 2 controls to do this, but I need it to be only one.
Thank you  
Message Edited by Heinen on 02-19-2009 06:16 AM
Message Edited by Heinen on 02-19-2009 06:20 AM
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.
Go to Solution.

I have a bit different problem.
I have a tab control, with several buttons on different pages.
In the current situation, we can talk about two pages, where one page ("Settings") in the Image, has a START and EXIT button, while second page ("Wait") has an EXIT button.
In a while loop, I have event structure, which handles events of the START and EXIT buttons of the Settings page. This is fine. But I also want to control the Exit button of the Wait page.
The control works like this:
When I click on Start in the Settings page, the front panel shows Wait page and attempts to connect to a datasocket server on the remote computer. If the user wants to stop this process, he can click on Exit on Wait page too. But, this doesn't give any immediate effect. On the even of Start button, the front panel is not locked, so the user can actually click the Exit button on the next page when it's visible. But it's of no immediate effect. Means, what the LabVIEW does is, finishes the execution of event in Start button's click, and while this executes, it doesn't consider the Exit button's refreshed value (shown in Red circle in the block diagram).
Simple question: Is there any way to check the updated (latest/live) value of a control during some event's execution? Or if I write an Event "Value Changed" for the Exit button and pass it to some variable. Is it the only solution?
Thanks ahead.
terminate event_diagram.jpg ‏200 KB
terminate event_front_1.jpg ‏63 KB
terminate event_front_2.jpg ‏63 KB

Similar Messages

  • How to stop a while loop of event structure from a main vi

    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    Go to Solution.
    stop a while loop and event structure from main vi.png ‏16 KB

    IYED wrote:
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    If this is an example of how your code looks, I'd clean it up before the developer who has to work on it next hits you over the head with his LabVIEW Style Book. 
    (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.

  • How to stop while loop when a specified function is terminated?

    I want to make a program which has 2 thread, one of which is to control some devices, and the other is to measure outputs of the devices.
    To do that, I should make a 2 independent loops, but there comes a problem here.
    I want to terminate 2 loops at the same time, but it's difficult for me to do that, because when I try to notify upper sequence's termination to lower loop by some value change, they have some dependency.
    That's why I need your help. I want to know how to stop lower loop when the upper sequence's termination keeping their independency.
    Please let me know. Thank you.
    help.JPG ‏200 KB

    Is the upper loop commanding the lower loop at all?  I would think you would have some type of communication between the loops.  Just use that communication to send a stop command.  Or the next best way is to just simply use a notifier.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to stop while loop for particular time

                    public void test()
                   new Thread(new Runnable()
                        public void run()
                             //System.out.println("test ..."+i);
                             catch (InterruptedException e)
            public void startTest()
                    while(i < marquee_Str1.length)
                   marLbl1.setValue(marquee_Str1); //set value to textbox for perticular id
                   test(); // call thread function
    in this code while loop don't stop
    plz help me to stop while loop for certain period by using thread or other technique                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Yes.. the original problem would be your test() method put the sleep in an entirely separate thread of execution. So the thread is created then the method just keeps waiting. The while loop should directly call Thread.sleep... which you have apparently figured out!

  • How to stop while loop

    I can't figure out how to stop a while loop in my labview program. 
    When the user presses the Run arrow in the toolbar I want my program to begin reading the serial port for GPS messages.  These messages should be displayed on the front panel.  Currently I have this read/display in a while loop.  The program is also waiting for an extrenal trigger.  When that trigger arrives, I want to grab the current string from the serial port and save it and continue reading and displaying the serial/gps string.  This trigger starts the other parts of the program- signal generation, recording, and saving data which need to run concurrently with the serial/gps reading/displaying.  Once the AO and AI have finished and the data have been written to disk, I want the program to stop.  The serial/gps messages should be updating this whole time.  Only when the data are written to disk should the whole program end.  This whole sequence of events should only be done once when the user preses the Run arrow. 
    So far I'm unable to pluck the serial string when the trigger comes in if I'm watching the serial port all the time.  The program also doesn't stop when it finishes writing to disk because the read serial while loop is still running.  I don't want to use a front panel stop button.  The program should stop itself when the data havebeen written. 
    I'm really stumped on this one but I'm new to LabVIEW so I'm sure there's an easy solution to this. 
    Thanks for any and all help. 
    Attachments: ‏199 KB

    Dennis and altenbach-  Thank you both for your patience. 
    I was trying to do just what Dennis suggested-"As I said, setting a local variable is one way." even before posting to this forum, but I couldn't get my local variables to reflect changes made elsewhere in the program and I wasn't able to wire from them because they were writes.  The critical part I was missing was how to change a local variable from a write to a read.  It was staring me in the face the whole time- just right click.  When I finally found it, my problems were solved. 
    altenbach- thank's for putting the figures together.  I do understand the logic and wiring there, but I was really trying to avoid stop buttons.  The program should be smart enough to figure out when to stop.  And using local variables turns out to be one way of solving this.  I still have some clean up to do, but I've included my current working version just so you can see how I implimented your suggestions.  There's still a lot of clean up to be done, but I'm delighted to be able to watch the serial/gps messages until I'm done reading in data.  At first I had this stop variable set in the final sequence frame.  That didn't work because I wasn't getting to the final frame because the loop wasn't finishing.  Once I placed the stop variable in the same frame as the while loop it began stopping when it should. 
    If you have other comments/critiques about the wiring diagram I'm earger to hear them.  I'm considering the structure finished, however.  It still needs cleaning up and commenting, but I'm satisfied with the functionality. 
    Attachments: ‏210 KB

  • Quit while loop in event structure

    I used event structure in my application and I would like to quit a while loop in an event structure when I pressed a control. But I have a problem because I'm in the event.
    Do you have a solution.
    Attachments: ‏34 KB

    connect a true constant to the While loop conditional terminal in the STOP event case.
    See your example modified.
    Good luck,
    Problem[2].vi ‏35 KB

  • How to stop while loop from looping

    Hi, need a little help in the respect to while loops. Basically i have a while loop within an while loop within another while. So what i want to do is run the program within the outer while loop. The problem is that when i start the program it runs once, which is ok, but its the runs again and again and again. I need it to only run once untill i press the inner while loop bolean to set it going and to stop and to restart, but i can not manage to keep the inner loop from initerating. I just wonder if its a problem with the field point? because i know it works, but using a different example. Any help greatly appreciated.
    Thanks Stuart
    examplealib.llb ‏199 KB

    Use case structures around your middle and inner loops tied to the booleans you want to control the loops. Inside each loop, use a local variable of the boolean tied to the continue terminal of the loop.
    You need to use local variables because an input to a loop (wired from outside the loop) is read only on the first loop iteration. Any subsequent change to a control terminal outside of the loop is not seen by the loop.
    To create a local variable, on the diagram, right click on the terminal of interest, then select Create >> Local Variable. Then right click on the local variable and select Change to Read.
    P.S. You know your stop button is wired to an empty case and doesn't do anything.

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link:
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, which is just a loop displays the count*2 (number of seconds passed since running) that will call and then check to see if the stop button is pressed. is by no means a state engine, it is just a simple loop for demonstration purposes. just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    Attachments: ‏17 KB ‏33 KB

  • How to handle event structures for two buttons and two counters.

         *I have two buttons A and B, and have to compare the difference in hits between them.  So do I place an event structure within a while loop for each button (2 buttons, 2 event structures, 2 while loops), or does it need to be one event structure with cases for both buttons whithin one while loop? 
         *How do I pass the values of buttons A and B's hit counters out of the while loop in order to calculate the differences between them after each increment, not just the final count after the stop button is hit? 
         *How would I make one stop button work to handle both buttons A and B?   I tried to place the actual stop button in one button A's structure and its global in B's structure, but It wont seem to let me use a local variable for a latchable control

    You should probably have not started a new thread and waited until your question in the original thread was answered. You can modify altenbach's example for a second button. You have a single event structure with a new event for the second button. You have a second shift register to track the number of times the second button is pressed. Inside the while loop but outside the event structure, you just have a subtract function in or to report the difference. do not modify the posted example for the stop button. It works perfectly as is.

  • Can I have multiple event structures with the same event cases?

    I'm doing an application that reproduces the front panel of the HP6675A power supply. To achieve this, I have done a state machine with different states
    (initialize, measures, voltage, current, ocp, ov, store, recall, etc). In each state, should have an event structure that catches the events of the buttons, like for example: if the current state is the Voltage mode and the user press the current button the next state will be the Current mode. For this in each state of the state machine should be the same event structure with the same events.
    My problem is that the Vi doesn't work properly when I have multiple event structures with the same event cases. There are some possibily to do this, and how? Or is impossible to have multiple events? I have been reading some posts, but I don't find solutions. 
    Any help is appreciated.
    Thank you very much.
    Go to Solution.

    natasftw wrote:
    Or as others mentioned, make two parallel loops.  In one loop, have your state machine.  In the other, have just the Event Handler.  Pass the events from the handler to the state machine by way of queues.
    A proper state machine will not need the second loop.  The "Wait For Event" or "Idle" state (whatever you want to call it) is all you really need in order to catch the user button presses.  The setup is almost there.  Maybe add a shift register to keep track of which state to go to in the case of a timeout on the Event Structure.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is it better to have one Event Structure with more (10 or 15) cases or several with fewer?

    I have several buttons and events on the GUI of my app to monitor. Would it be better to use one Event Structure with several cases (10 or 15) or have a couple and split the cases evenly? None of the cases have much processing to handle, so there is not a time lag issue. I am just worried about overloading the structure. One of the tech support guys mentioned that the event structures are not that hard to get confused.
    Has anyone had any problems with Event Structures?

    I use event structures very often in my code. I use them just to handle the interface and to run small code. I have had event structures that handled over 50 user interface events and never had a problem. In my personal opinion If there was any code to run I would let the event structure handle the the user interface event that fired a que in another while loop that handled the code.You can find examples on this, if not I will send you one. It is just good programming practice for beginners because it will alow you to build more robust VI's in the future.
    Hope this helps

  • Event Structure with Event source: This VI and Event: Mouse Up

    I downloaded an old example from 2008 on this forum and would like to duplicate it.  It uses an event structure with an event case of just Mouse Up.  Under Event Specifiers:  the Event Source is <This VI>  and Event: Mouse Up.  This works like I want in LV 2009.
    In LV 2009 if I choose for Event Source  <This VI>   under Events Mouse Up is not an option!    I tried Event Source: Pane,  and  then Event  Mouse Up is an option, but this does not trigger the event if you drag the mouse off the pane before you lift the mouse button.
    I can copy the Event Structure over to my VI  and rewire every case but that does not seem to be a good solution cuz I want this in several VIs.
    I have attached the original VI with the Event Specifier I want.  How do I get this Event Specifier in LV 2009?
    Slider event ‏19 KB

    phillman wrote:
    I downloaded an old example from 2008 on this forum and would like to duplicate it.  It uses an event structure with an event case of just Mouse Up.  Under Event Specifiers:  the Event Source is <This VI>  and Event: Mouse Up.  This works like I want in LV 2009.
    In LV 2009 if I choose for Event Source  <This VI>   under Events Mouse Up is not an option!    I tried Event Source: Pane,  and  then Event  Mouse Up is an option, but this does not trigger the event if you drag the mouse off the pane before you lift the mouse button.
    So what you can do is monitor the 'Mouse Leave' event for th pane, and then start polling the mouse state.
    Technically it is correct that there is no Mouse Up event detected since the Mouse Up is not happening on th epane.
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • CUOM 2.3 sends multiple notifications for Event StoppedGSUPerformancePolling with same time stamps

    Hi Alll,
    I have a CUOM Version 2.3 which shows mutiple notifications per Device for Event StoppedGSUPerformancePolling with same time stamps. The message below is generated from the default All_Events for all devices.
    Does anyone have a solution for that.
    Regards Michael
    This message is generated 8 times with the same time stamp in all messages.
    ** This message is generated from Cisco Unified Operations Manager **
    ALERT ID                = 00012OW
    CREATION TIME           = Sat 30-Oct-2010 16:31:57 CEST
    MODIFIED TIME           = Sat 30-Oct-2010 17:00:58 CEST
    STATUS                  = Active
    SEVERITY                = Critical
    MANAGED OBJECT          =
    MANAGED OBJECT TYPE     = VoiceGateway
    CUSTOMER REVISION       = Voice Port

    if you get SNMP timeout on multiple devices then the fault usually lies in the path that the polling follows to get to these devices and back to the server.
    The problem obviously lies in the part path they have in common.
    It is not unusual to see the highest backbone loads during the night, due to backups being taken.
    Make sure the most important inter-switch links have no errors.
    I would rather fix this then turn off alerting.

  • How do i exit a while loop using event handler

    I have an event handler structure within which i run a while loop for a particular event. I would like to interrupt the execution of this while loop as soon as another event occurs, even if the while loop has not finished execution. I have tried so many ways, the best i could get is exiting one itteration after the new event occurs which is no good for me.
    Any suggestions???

    Instead of having a task while loop in an event case, put your task while loop in parallel with the loop surrounding the event structure. When the event which should start the task occurs, you can signal the start of the task while loop. You could use local variables of references to start/stop the loop when an event occurs. You could also use notifiers instead of variables to pass signals to start/stop the while loop. In general you should have a while loop for the event structure, and a parallel while loop to do the tasks. The parallel loop is controlled by variables or notifiers which are set in the event cases.
    - tbob
    Inventor of the WORM Global

  • How to EXIT the while loop in Event response section?

    I'm writing a program to grab image using a NI card. The application uses the Event structure. When the GRAB button was pressed, it snaps image continually by putting the SNAP function in a while loop. Is there some way to exit the while loop?(Note :The while loop was put in the GRAB IMAGE event response section.)

    edit this event-case AND uncheck "lock front panel until the event case for this event completes".
    BTW, your thanks should go to Ankita, <a href=''>here</a>
    Message Edited by Dynamik on 11-13-2005 01:26 AM
    Message Edited by Dynamik on 11-13-2005 01:38 AM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    untitled.GIF ‏20 KB

Maybe you are looking for

  • Low resolution warning on pics

    Hi. I'm new to this iPhoto app and not very good or experienced with photos!! And I need help!! I received a CD with some pics on whihc I saved to my desktop as .jpg images. I then imported them into iPhoto 6.0.5 and they appear fine. However, when I

  • Apple TV and Family sharing with child

    I have an Apple TV 3rd Gen unit. Debating on getting a second Apple TV for my daughter. I would like to know, with Family Saring, Can I choose the movies and TV shows she is able to view on her Apple TV? She is 12, created her ID before the child ID

  • Itunes music downloaded to iPad 2 but doesn't show up under "music" app

    We have a lot of music in iTunes on the Mac, most of which is from CDs we own. We synced to new iPad 2 and it shows they all went in, but can't get any of the music to show. the "music" button says nothing is there. the "Itunes" button only takes us

  • Need help on xml publisher 5.6.2 for E-business suite

    Hi, we are on 5.5.X now, i tried to find a install guide and download patch for 5.6.2 for E-business Suite but could not find any. Can you point me to the right place. Thanks, Message was edited by: tlcal1

  • SID Name in oracle 10g

    Dear Experts, how I can find SID name in Oracle 10g databse, which i forget. thanks in advance