Multiple event structure in a while loop

Dear All,
               I had a multiple event structure inside a while loop. The purpose of doing so is because I had a few 2D picture on the front panel. I would like to detect which 2D pictures had been click using the mouse down event structure for 8 of my 2D pictures.
              The problem that I faced now is that when I of the event case or one of the 2D pictures had been click, it will not exit the while loop. I had to click on all the 8 2D pictures before it will exit the loop.
              I had uncheck the under the "Edit Event" --> "Lock Front Panel (defer processing of user action) until this event case completes". But I am still stuck inside the loop.
              Each 2D picture will perform different action therefore I cannot have an event case of all 2D pictures inside else I would know which 2D picture had been click.
             Is there any other way out of this situation? Pls help. Thanks a lot

A producer/consumer architecture (look at the examples that ship with LabVIEW) is comprised of two parallel while loops. One loop contains the event structure. The other contains your consumer which is basically a queued state machine. It receives messages from the producer via a queue. Your event structure can register a separate event for each 2D picture control or it can use a single event that would determine which spefic controls was clicked on. This is a more general approach and expands easily. Here is a basic example of what I am talking about.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Attachments:
Event Producer-Consumer.vi ‏14 KB

Similar Messages

  • Event Structures and Do /While Loops

    I have an Event Structure inside a Do/While Loop.  One of the buttons in the event is STOP which stops the do while.  The Stop Button itself is inside the event as suggested in the help.  My problem is when I hit the stop button everything inside the Do/While runs 1 more time.  Other than than the code works perfectly.  is this normal behavior for a Do/While ..Event Structure??

    The attached file is the code in a nutshell.  I know it can sometimes be diffcult to TS w/o the actual code.  Prob is I wrote it in LV2011 on the Lab PC and I have LV2010 at my desk.  I don't have internet access in the Lab..of course.
    If I hit the OK button 2x's it "does something...does something...build array" then again a second time.  The build array is added to with each click of a button in the event structure.  If the user hits the STOP it dumps the 2x's worth of data out to excel..except I get 3 rows of data rather than 2...as if the inner loop ran one more time.
    Anyways. the only thing that caught my eye is the fact that I don't have a sequence structure around the "build data here" portion of the code.  Would that affect how the STOP inside the do while loop is handled??
    Attachments:
    event_Do_While.JPG ‏90 KB

  • Event structure in a while loop does an extra iteration

    In this program, after the user has measured all the values, he or she will press a calibration complete button and the results of the measurement will be displayed.  However when the program runs and this button is pressed, the event structure does one more iteration.  Is there a way for the while loop to read the control before the event structure executes to prevent this?
    p.s.  I know that the wiring is probably a lot more complicated than it needs to be so if there is a better way to place values into a particular space in an array let me know
    Thanks
    Chris O.

    Probably just a matter of the order of execution in your data flow.
    Please post a VI so we can see what is going on now.
    Never mind.  You have since posted it.  SMerucurio's suggestion of a separate event case for the other button should work fine.
    Message Edited by Ravens Fan on 06-30-2008 01:20 PM
    For putting an element into a specific location of an array, look at "Replace Array Subset".  This should allow you to replace your groups of shift registers with a 1-D array since you are basically building 1-D arrays after your case structures anyway.
    Message Edited by Ravens Fan on 06-30-2008 01:24 PM

  • Stopping an event structure inside a while loop.

    I am relatively new to LabView, and especially the event structure. I have been looking at previous posts regarding the event structure and people having trouble stopping it. In my VI, I have two event cases in addition to the timeout. I am using this VI for stepper motor control. I have 2 buttons (for each case), one for movement to the left, the other to the right. It runs like it is supposed to, but when I try to stop it I have to press both buttons before it stops. As if the loop has to execute everything inside before stopping.
    In my VI, how can I make the execution stop when I press the stop button? I tried many setups of the stop button and boolean logic (which I believe was correct) but am now stuck.
    Thank you very much ,
    Alek
    Solved!
    Go to Solution.
    Attachments:
    motor control2.vi ‏24 KB

    OK, here's my simplified version. All you need is two event cases.
    Note that (with a tiny difference), the "left" and "right" cases are identical, so they can be handled in one event, reusing most of the shared code.
    We don't need a timeout event
    Just some extra tweaks...
    Message Edited by altenbach on 06-23-2008 05:09 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RightLeft.png ‏13 KB
    motor_control2MOD.vi ‏15 KB

  • Multiple event structures in one VI

    I have two event structures in a single VI, one that handles events that freeze the user interface and one for events that don't. The latter group are all triggered acquisition tasks, where you arm the  data acquisition, but possibly might want to abort it (or do other things, while waiting for the data to come. Obviously you need a stop button to be active and responsive. In retrospect, using two loops was possibly a poor choice, but one I made because it never occured to me that these things would only fire once and have to be put in a while loop to be kept active. No other language does that as far as I know. Anyway, the question is how do I keep both active? Do I enclose both in a single while loop? Do I give each there own while loop. Do I give up and merge the two event structures into one. For clarity I would like to keep them seperate, but that is not essential. I'ld like to know what my options are.
    Solved!
    Go to Solution.

    rossu wrote:
    If they are in sperate while loops will they both run. If they are in one loop will the loop recycle if one structue is still waiting for an event to occur?
    The answer to this is fundamental to how LabVIEW works. A loop will not proceed to the next cycle until everything inside it completes. If you have two event structures in the same loop, both of them need to process an event (or a timeout) before the loop will iterate.
    You can have multiple event structures in the same VI.
    By "freeze the UI," do you mean the "Lock front panel..." checkbox in the event dialog? There is no problem with having some events that do lock the front panel and some that do not in the same event structure. I'm not sure that this is what you mean by "freezing" the UI, though.
    EDIT: and one more comment. Generally you should not put long-running tasks (like data acquisition) inside an event structure. Instead, the event case should pass those tasks off to a separate loop (for example using a queue) so that the event structure can quickly go back to listening for other events.

  • Using multiple events structure inside state machine to control the Tab

    Hi y'all,
    Anne here.I have a Tab indicator in my front panel and I want to be able to control the flow of my program based on what controls I clicked inside the tab. I am using a state machine architecture and inside every state, I use an event structure to check for user interaction  to determine the next state and what tab page is going to be displayed next. This means that I am actually using multiple event structures in my application and I use them in just one while loop, but just that they are not running in parallel since I am only using "one event structure per state" which means that only one event structure is running at one time. My questions is, programming technique wise, am I doing it correctly? So far, I am not facing any problem (I am still in the early stage of the project) but I want to check with you all first on your opinion regarding this architecture. Will there be any issue on using multiple event structures in a vi? Since I will be using a tab, and the controls available in the tab will be the controls that will control my event structure for that state, by right, there should be no issue. Am I correct to assume this? Is there any limit on the use of event structures? I have attached here a simple sample of the architecture that I am talking about for your reference. I have attached a 2010 version and a 8.6 version. Let me know what you think or any opinions that you may have.
    Hoping to hear from you soon! Thanks so much in advance!
    Cheers!
    Anne
    Attachments:
    State Machine-Event Structure Sample_2010.vi ‏19 KB
    State Machine-Event Structure Sample_8.5.vi ‏25 KB

    Hi jak888,
    I decided to use tabs cause I don't want to have subvi pop ups every time i need to perform the process in the state and show an update in the front panel. This is actually going to be more of an ATE where you will have to choose first whether the one using is the operator or the engineer. If the operator is logged in, she will proceed to choose what test to run (this state will have its own event structure). This part, I don't want a pop up, so what happens is that from Login page, if the user logs in as operator, the tab will automatically switch to the Test Selection page. After selecting the test, it will proceed to Start Test state and the tab will show the Result Summary page. If the user logs in as engineer, then a totally different tab will be automatically shown next and so on. By doing this, I will be able to show an update on the front panel objects without having the subvis pop up. I will also just need to use the call reference functions to call my subvis, making my Main VI more generic. The tab Page header will be hidden so the operator will actually not see that there is a tab and that there are a lot of controls and indicators cause they are hidden in the tabs and that page will only be shown based on what they selected from the main tab. 
    I appreciate your thoughts! thanks so much!

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

    Hello, 
    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.
    Solved!
    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

  • Multiple event structures in one program

    I know it's not good practice to have one event structure inside another event structure (I don't know exactly why). But if another event structure is in the subvi, is it safe? Please comment.

    guangdew1 wrote:
    I know it's not good practice to have one event structure inside another event structure (I don't know exactly why).
    This is because of dataflow and the way event structures work. If you have an event structure inside an event structure, both event structures will accumulate events whenever one occurs, but it is unlikely that they can be handled in the order they occur or at all. By default, event structure are set to lock the front panel until the event completes, meaning that if an inner event gets triggered first, the code will lock up, because it will no longer be possible to trigger one of the outer events. If the outer event occurs first, it cannot complete, because it requires a later firing of one of the inner events before it is ready to handle the next event that occurs in the UI. Even if it marginally works if the panels don't get locked, you are requiring the user to trigger events in a certain order. How is he supposed to know what's allowed or not?
    If this is not exactly clear to you, you need to start with a few tutorial and learn about dataflow, Then start using a single event structure and see how things work by programming scenarios and see what happens.
    guangdew1 wrote:
    But if another event structure is in the subvi, is it safe? Please comment.
    Event structures are only useful inside interactive subVIs that show their front panel. even then I strongly advise against calling anything interactive, or anything that takes excessively long, inside a main event structure. You end up with code that can become unpredictable, can deadlock, is hard to debug and flies in the face of all good programming guidelines.
    Obviously, you have some specific application in mind where you think something like that is useful, I can guarantee you that there is a much better solution is you think about this a bit longer. If you need help, please describe exactly what the program should do and how it should react to user interactions at the various stages.
    A program should always be approached from the code and UI needs. Don't start with a harebrained code construct (events inside events) and then look for a use. It does not exist! 
    Event structure only belong in toplevel loops. They should never be hidden insde squences or case structures (or other event structures as already mentioned above). If you have multiple toplevel loops that run in parallel, it is safe to place up to one event structure inside each. Each event structure can have an unlimited number of event cases. This should be sufficient to handle any programming need you might have.
    LabVIEW Champion . Do more with less code and in less time .

  • Code driven event handling in a while loop

    I have an event driven while loop. Is there any way to trigger an event by code and not by any user action? Sometimes I need to execute the while loop once but I don't like to use the timeout event because it causes some trouble in my timecritical application.
    Thank you in advance,
    Andreas Langer

    Andreas,
    The following page has an example on how to accomplish this:
    Generating an Event in LabVIEW Programmatically
    http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/c0128a70970d0a0386256b48008366be?OpenDocument
    Zvezdana S.
    National Instruments

  • Multiple Event Structures - LV8.0

    So why does this program hang?  I know that it is best to use one event structre but why?  It seems for a simple application that this should work.
    Matt
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
    Attachments:
    multipleEventDiagams.vi ‏15 KB

    That certainly explains the hanging you saw. Remember that Event Structures by default will lock the front panel until the event case for a given event occurs. So in your VI, if you press Button 2 once, then you terminate the bottom loop. But the event structure is STILL registered for the Button 2 event. So when you press Button 2 again, the front panel gets locked, because the bottom event structure will never get to execute again (its loop has been terminated).
    You could have fixed this (I realize it all boiled down to a mis-wired connection) by unchecking the check box in the Edit Events dialog for your Button 2 Value Change event case that says "Lock Front panel until...".
    Hope this explains this, even though you've solved it!
    Jarrod S.
    National Instruments

  • Multiple events structures for same control

    Hi,
    I would like to use a same blinking button into 2 event structures seperately.
    Please see my VI, after the first event is done, the second event is not wait for user to press the button, and it is auto triggered.
    How to solve that? Is there any way to reset the event?
    Thanks.
    Attachments:
    2 events.vi ‏13 KB

    It is also not clear what you are trying to do with the blinking. In your code, the LED will blink basically always. (you don't use the timeout event).
    In the first frame, blinking is enabled. Nothing happens in the second frame until the start event occurs. At this time blinking gets disable for about a nanosecond and gets immediately enabled again in the third frame. Even if the second eveng would not execute, you'll never see a difference. So what's the point?
    Here's a quick draft where each press of the start button toggles between blinking and not blinking. Maybe it can give you some ideas.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    2 eventsMOD.vi ‏10 KB

  • Event Structure Freezes Vi After Capturing The First Event

    My Event structure catches the first instance of my button press but then it freezes my Vi.  The reason is because of the while loop but I need the while loop to constantly read from a serial port and send data to a serial port. The vi included is stripped down to be just a while loop that does nothing.  I have also tryed putting the event structure in the while loop, but the same thing is happening.
    Any ideas?
    Thanks,
    Cason Clagg
    SwRI
    LabView 7.1, Windows XP

    Also, put the button inside the event structure where it is acted upon, from LV help (suggest you read the entire events section of help):
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

  • How to make an Event Structure work with a webcam feed?

    Hello,
    I'm pretty new to LabVIEW, and I really need some help on a school project.
    In the program, a webcam contantly streams video.  At the same time, I am trying to add an event structure inside of the while loop that contains the webcam information.  An event structure seems to be just the thing I need to add to make my program work, but after adding it, the webcam stopped showing its feed.  My guess is that it's specifically not working with the webcam part, because I've used event structure inside of while loops before.  How can I prevent the event structure from interfering with the webcam?
    I cannot take a screenshot of the back panel at this time, although I can do it within the next 24 hours, if necessary.  Otherwise, I can try to describe the program to the best of my ability.

    i did this a while back for my school project.
    see if its what you need
    Best regards,
    Krispiekream
    Attachments:
    Executive.zip ‏183 KB

  • Can I use Event structures in a subVI?

    Hi,
    I have a subVI (ProvaEv1.vi) that use an event structure inside. But when I use it in a VI (ProvaVI.vi) the event structure in the subVI doesn't catch the events.
    I tried to insert the event structure in a while loop but it doesn't work too.
    Could you help me?
    Thanks Ius
    Attachments:
    ProvaVI.vi ‏11 KB
    ProvaEv1.vi ‏15 KB

    "iusn" <[email protected]> wrote in message news:[email protected]...
    Thanks to all for your answers!
    Wiebe! I tried to do as you suggested but I am not able to link the Event Reference Number inside te SubVI with the Event Register Number of the Register for Event in Main VI. There is e class conflict. Another question: how the SubVI can know the structure of the Register event outside?My aim was to create a modular structure but it seems very difficult, wath do you think about these problems?
    The broken wire is related to your question. The event structure inside the sub vi knows about the events you register in the main, because the reference wire/control has a "strong" type. It contains information about the registered events. That is also why the wire is broken. You have to register all events, then create an indicator/control of the output. Use that control in the subvi. You have to do this every time the events change (you might use a type def if you use the control a lot).
    Usually, the events that you would want to put inside subvi's are those related to user interface objects. I've had this a lot. You make a nice interface, but it's not reuseable, because the events are mixed with all the other events. Only solotion is to manually add the needed event cases in your program, and copy the code.
    Even if you can put the events in a sub vi, I'd expect hanging vi's when more subvi's are registered for the same event. It's hard to tell without trying. So it's not a real solution either.
    Like Chrisger suggested, the event callback might help a little, but they are tricky, and actually ment for this (they are intended for activex callbacks).
    Perhaps you should look at XControls (if you use 8.2). It would be more work to replace your code to XControls, but once you're done, you have reusable code.. Haven't worked with them jet, but they are invented for this problem...
    Regards,
    Wiebe.
    I have already create my application using event structure just in Main VI but it seems very complicate to read and keep update, I would have wanted to give modularity to my application.
    Thanks Ius
    SubVIEventMain.vi:
    http://forums.ni.com/attachments/ni/170/203225/1/SubVIEventMain.vi
    SubVIEvent.vi:
    http://forums.ni.com/attachments/ni/170/203225/2/SubVIEvent.vi

  • 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
    Checker

    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.

Maybe you are looking for

  • Copying and pasting from Adobe Photoshop CS4

    Does anyone know how you can copy and paste text that you enter in "Description" in the "File Info" section of a jpg file across to other applications. It would save me countless duplication of having to write the description on emails to which I att

  • Adobe Acrobat XI Standard - SN issue

    I click on "Abobe Acrobat XI Standard".  "Validating Serial Number....".  Box pops up "Serial Number Upgrade".  I select the Product "Adobe Acrobat X Stqandard".  I enter the SN indicated on my order confirmation.  And click Next.  Immediately receiv

  • Ewfmgr: Failed getting protected volume configuration with error 1

    Hello, I created a Windows 7-64 image for an Ivy-Bridge VME card. The image contains EWF with RAM-REG. The disk was divided into 2 partitions with the windows installer and the image was successfully installed. As I'm using RAM-REG, all the disk was

  • Solaris 11 Early Adopter - hostname changing changes?  :)

    I see that the "old" way of changing hostnames from Solaris 8/9/10/11-Express has changed, but I can't get the new way to work in the Early Adopter release. The docs say to use this command: svccfg -s svc:/system/identity:node setprop config/nodename

  • Java sleep on startup 12minutes

    Hi to all. There is a desktop application that run with JVM 1.6.0_b02 that during startup slept about 12minutes. The pc is based on Windows XP PRO Sp2, centrino solo 1.6GH, 1GB ram. Whith ProcessMonitor I see this info: 2005452     8.52.37,2115016