Tutorial on Event handling structure in labview

Hello,
can some one suggest a tutorial on event handling? I want to understand about the adavanced feature of the event handling structure like the dynamic even handling. Further is there any tutorial and examples using the user defined even handling function?
Regards
Gopal

Hi,
Thank you for those links. I would also like to know about the event menu in labview.Which has functions like create user event, register user events etc., further in event structure there is an option called show dynamic event terminal. what is its purpose and when and where should it be used?
Regards
Gopal

Similar Messages

  • Event handling using CAN?

    I am aware of how to make LabView respond to user interface events (keyboard presses, button presses, mouse moves, etc) and I'm also aware that the same event handling structure can be used to handle external (non-GUI) events- like those generated by a digital edge on a DAQmx input.  My question is whether the same event handling structure can be used to handle external events coming in on a CAN network- via NI-CAN or otherwise?
    Is there a good reference which summarizes ALL general types of events that can be handled in this way- not just the standard GUI events?  I have a feeling that ActiveX and VISA are other ways to generate events, but can't find a good resource in general - or specifics on the NI-CAN side.
    Thanks!
    Nate 

    Thanks Mike-   still not sure I understand.  What should I wire to the Create User Event block in order for available events to show up in the dialog which allows me to configure events in a given frame?  For example, I have an external micro-controller communicating with LabVIEW using a CAN network.  Usually the communication is started by LabVIEW and sends commands out- but I also want to be able to handle asynchronous messages generated by this micro-controller in an event fashion without having do any polling.   Is there some reference I can wire to the Create User Event block which will make an event like "Incoming CAN Network Traffic" available to be handled in an event structure?
    Thanks again! 

  • Queue based UI Event Handler Pattern (CLD)

    Hi, everybody:
    I am trying to get a better understanding of the Queue based UI Event Handler pattern in CLD exam. So I made the attached small LabVIEW program in which 3 buttons(State 0, State 1, State 2) are the 'switches' of 3 LED lights (S0, S1, S2), respectively. After comparing with the Queue based UI Event Handler pattern in NI's slide, I got some questions at the following points:
    (1) There are six items(Initialize, Waiting for Event, State 0, State 1, State 2 and Stop) in the Enum constant in my program. To make this program use standard Queue based UI Event Handler pattern, should I only use 3 cases(Initialize, Waiting for Event, Stop) in the case structure and put 4 events(State 0, State 1, State 2 and Stop) under the case of 'Waiting for Event' ? Is what I coded a standard Queue based UI Event Handler pattern?
    (2) In the attached screenshot of Queue based UI Event Handler pattern in NI's slide, I found 'Start' is wired with 'Enqueue Element.vi'. Why is that? Should there be a 'Start' Case in the case structure?
    (3) In my program, I wired 'Waiting for Event' with 'Enqueue Element.vi' in all events except 'Stop' event. Should I wire 'State 0', 'State 1', 'State 2' with 'Enqueue Element.vi' in their corresponding events, just like my second question in NI's slide?
    BTW, I didn't find the exact Queue based UI Event Handler pattern in LabVIEW 2011, Should we code it by ourselves in the real CLD exam?
    Thanks a lot in advance!
    Chuan
    Attachments:
    Queue based UI Event Handler Practice.vi ‏18 KB
    NI Slide.png ‏177 KB

    Chuan wrote:
    Hi, everybody:
    I am trying to get a better understanding of the Queue based UI Event Handler pattern in CLD exam. So I made the attached small LabVIEW program in which 3 buttons(State 0, State 1, State 2) are the 'switches' of 3 LED lights (S0, S1, S2), respectively. After comparing with the Queue based UI Event Handler pattern in NI's slide, I got some questions at the following points:
    (1) There are six items(Initialize, Waiting for Event, State 0, State 1, State 2 and Stop) in the Enum constant in my program. To make this program use standard Queue based UI Event Handler pattern, should I only use 3 cases(Initialize, Waiting for Event, Stop) in the case structure and put 4 events(State 0, State 1, State 2 and Stop) under the case of 'Waiting for Event' ? Is what I coded a standard Queue based UI Event Handler pattern?
    What exactly are you trying to do with this program?  Just using it to show a basic pattern for review? 
    Seems like you are trying to use Queues, a Case Structure, and Events all in one loop.  Be careful not to try to be so advanced for this test.  I still can't seem to figure out what the question you are trying ask is, but reply and we'll see if we can figure out an answer.  You can put as many "states" in an Enum as you want but just not use them all during the program.  I use fillers sometimes "just in case" I need to use it.  Obviously, don't do this for a real program. 
    (2) In the attached screenshot of Queue based UI Event Handler pattern in NI's slide, I found 'Start' is wired with 'Enqueue Element.vi'. Why is that? Should there be a 'Start' Case in the case structure?
     Your code is your code.  This is just an example of the way that you could do it if you wanted to.  You need to read the requirements document to determine exactly the way to Initialize and Start and whatever else your program.  Typically, I've seen the following included in software using this structure:  Initialize, Start, Run, Stop, Update Settings, Exit...and so on.
    (3) In my program, I wired 'Waiting for Event' with 'Enqueue Element.vi' in all events except 'Stop' event. Should I wire 'State 0', 'State 1', 'State 2' with 'Enqueue Element.vi' in their corresponding events, just like my second question in NI's slide?
     Well, you never ended up using the Initialize case.  You need to Initialize outside the loop in your program.  Again, try to explain your design more.  It seems like what you have done is right, but I'm not sure what all you are trying to accomplish.
    BTW, I didn't find the exact Queue based UI Event Handler pattern in LabVIEW 2011, Should we code it by ourselves in the real CLD exam?
    All code on the CLD needs to be your own.  Templates are just there as a starter for people who are not familiar with them.  If you want to take the CLD, you should be at the point where you don't need the templates to do the work for you. 
    Thanks a lot in advance!
    Chuan
    See my responses above.  Best of luck.
    The pattern you have used in your program is *technically* fine, but in all the code I wrote for the CLD and in most of the examples I saw, everything was just a state machine with a enum driver.  Be careful trying to violate the norm on this as you will likely run into more problems than solutions.  You could also encapsulate your Queue into an FGV, which would modularize the code and look a little neater.
    Nathan - Certified LabVIEW Developer

  • How do i exit a while loop using event handler

    Hello,
    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???
    Thanks
    Me

    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

  • Event Handling in labview with arrays as event data

    Hey folks,
    I have a Labview Application which uses a dll to read Ethernet data. The setup is such that, when the dll has fresh data it sends out an event to the Labview Application so that the fresh data can be displayed.
    However i have only managed to get this event based mechanism to send out a single structure at a time. Hence if there are 10 fresh data values, i need to send out 10 events (each event structure contains the parameter name, parameter value, unit and time stamp). It would be more efficient to send out an array of structures in a sigle shot.
    I have tried this but Labview keeps crashing saying that an error was encountered and Labview needs to close along with an access violation message. I did a lot of online searching and found some LV code for event handling but not come accross any implementation which uses arrays as evend data. Is this supoorted? And if so is there any example vi that can be shared so that i get some knowledge about this.
    Many Thanks in adavance,
    Abel. 

    I also gave a try by using a variant as the event data type instead of the cluster which contains the array of floats. I converted the cluster into a variant and used that to create the user event reference. Followed the same logic while decoding the dats.
    But still the crash.... Here is the windbg output...
    ModLoad: 07580000 075b7000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvalarms.dll
    ModLoad: 0ca90000 0cb72000 C:\Program Files\National Instruments\LabVIEW 2012\resource\mesa.dll
    ModLoad: 0c7f0000 0c7f9000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvuste.dll
    ModLoad: 35000000 3509b000 C:\Program Files\National Instruments\Shared\TDMS\tdms.dll
    ModLoad: 0c860000 0c87c000 D:\SapphireViewer\dll\SapphireClientDll.dll
    ModLoad: 0e240000 0e2c7000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCP80.dll
    ModLoad: 0e2d0000 0e36b000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCR80.dll
    (1cb0.1a34): Access violation - code c0000005 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    eax=0e47f8b4 ebx=051f0040 ecx=051f0040 edx=061e5764 esi=22820840 edi=07b10040
    eip=03c2050c esp=0e47f5cc ebp=0e47f810 iopl=0 nv up ei pl nz na po nc
    cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202
    *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\National Instruments\LabVIEW 2012\resource\tdcore_12_0.dll -
    tdcore_12_0!LvVariant:etContents+0xac:
    03c2050c 837e3100 cmp dword ptr [esi+31h],0 ds:0023:22820871=????????
    I cannot really tell whats going on. Looking for some pointers.
    Regards,
    Abel.

  • Labview slider event handling problems - revisited

    This topic asked a question that was very close to a problem I am having:
    Labview slider event handling problems
    That is, how do I, using an event structure and/or other means, only read out the value of a slider control after the value change is finalized?
    The extra constraint I'd like to place on this, which I believe will invalidate the answer given in the thread above, is that my slider control also has a digital display which can also be used to change the value without ever using the mouse. I cannot look for a value change followed by a mouse-up event if the mouse was not used to change the value.
    Any ideas how this might be accomplished? FWIW, I am using LabVIEW 7.0

    Each and every incremental value-change event generated by the movement of the slider is still detected and queued up for use by the event structure and the event structure loop wades through them all before it's done.
    I have come up the attached "fix" (LV v7.0) for this problem. While it is not as clean a solution as I had hoped it would be, it's the best I can manage given what LabVIEW offers me to work with and it does work in the situation where I need to use it.
    Now, within the Finalize Slider Events subVI, I'm keeping track of the most-recent values seen by the subVI, checking to see if they have changed, and reporting out that fact. That gives me a Changed/Not-Changed bit within the event case that I can use to control what code then gets executed. If the event case is just playing catch-up to the real value of the control, I can now see that fact and ignore it.
    In this version I've also dumped the variant output and limited the VI to using DBL values. I decided it added complication to something that was too complicated already and I wanted the output terminals for other purposes anyway (reporting of the correct "OldVal" of the control).Message Edited by Warren Massey on 04-28-2005 03:56 AM
    Attachments:
    slider_events[5].llb ‏77 KB

  • Simulate event structure in LabVIEW base?

    I have a LabVIEW base version (v8.6) which does not have the event structure. I found it was quite inconvenient to monitor the status of several controls (the action after click a control depends on the status of other control(s)). Especially if I want to add another function (control), the effort increase exponentially with the existing number of controls
    I got an idea of simulate the event structure using 'Shift Register'. First, I will bundle all the values of controls into a cluster. Then I will put the cluster in a while loop, and compare the value of the cluster with its previous value (xor the shift register). If the compare result is false (none of the control is changed), the program goes to next iteration. If the XOR result is true (one of the control was changed), then the program goes into event handling code (it will pass which control has changed, and the whole cluster). So for each control change, we can write a independent code to process the event. After processed the event, the event was cleared.
    The following is a section of my ugly code currently used to monitor several controls. And I am thinking of rewrite it using above idea so that there will be less likely a hiden bug.
    Any comments of suggestions?
    Message Edited by RyanWu on 10-23-2009 10:16 AM
    Solved!
    Go to Solution.
    Attachments:
    UglyLabVIEWCode.png ‏18 KB

    Ben wrote:
    Altough this is an interseting academic question, we really can't duplicate the efficiency of the Event structure so springing for an upgrade is highly recomeneded.
    But I am not here to sell LV but rather help LV developers so...
    Start by developing an Action Engine with the following actions.
    1) Init -caches control ref for all controls and indicators for which you need an event. Optionally rest them and cache their state.
    2) Check - Will compare the current state with the prvious state and any changes get pushed onto a stack in the AE and if there are elements in the stack (due a change detected now or one left over form the last check) and returns a type-def'd enum describing what changed. Multiple changes should be on the stack for next time.
    3) Get New - will return the new value of the value requested via an Enum.
    In you top level VI use the AE to Init before you run and then use an "Check" method to se if anything changed. If it flags a change (boolean output of AE) then the Enum is used to select the proper case of a case structure. Inside the psuedo-Event case, you can use teh AE with the "Get New" action and pass the enum to choose which value to get.
    It is hardly an Event Structure but it should come close.
    Ben
    But after looking at Knickerbocker's* post we can go farther.
    Put the above code in a sub-VI that feeds a queue. Then you can monitor the queue for updates just like in an event structure AN you can queue up all of the changes at once and can ingore my mention of caching the change methods in the AE. Just let the queue handle the stack.
    Ben
    *Kudos for inspiration!
    Message Edited by Ben on 10-23-2009 10:54 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Question on program structure about event handling in nested JPanels in GUI

    Hi All,
    I'm currently writing a GUI app with a wizard included in the app. I have one class that acts as a template for each of the panels in the wizard. That class contains a JPanel called contentsPanel that I intend to put the specific contents into. I also want the panel contents to be modular so I have a couple of classes for different things, e.g. name and address panel, etc. these panels will contain checkboxes and the like that I want to event listeneres to watch out for. Whats the best way of implementing event handling for panel within panel structure? E.g for the the checkbox example,would it be a good idea to have an accessor method that returns the check book object from the innerclass/panel and use an addListener() method on the returned object in the top level class/panel. Or is it better to have the event listeners for those objects in the same class? I would appreciate some insight into this?
    Regards!

    MyMainClass.main(new String[] { "the", "arguments" });
    // or, if you defined your main to use varags (i.e. as "public static void main(String... args)") then you can just use
    MyMainClass.main("the", "arguments");But you should really extract your functionality out of the main method into meaningful classes and methods and just use those from both your console code and your GUI code.

  • Canoe Event Handling in Labview

    Anybody worked on handling the events of CANoe in Labview?
    I am trying to handle the event when there is a value change in the environment variable of CANoe. CANoe provides a COM method "OnChange" but i do not know how to implement this method in Labview. This method is available in CANoe -> Application-> Environment->EnvironmentVariable-> then event OnChange.
    Any ideas??
    Thanks,
    Suhas

    Hello,
      I'm willing to handle the same process as you, but I did not yet success. I attached my project, and I think my problem is more Labview than CANoe. If you successed or if anyone already have done such diagram with VICallback and Event Data, please have a look, I'm really fighting without success now.....
    Attachments:
    CANoe_Graphic.vi ‏22 KB
    sub2.vi ‏12 KB

  • Event Handling for tree structure using "CL_GUI_ALV_TREE_SIMPLE"

    Hi,
    I have created a tree structure using class CL_GUI_ALV_TREE_SIMPLE.
    Now I wanted to insert a check and give message when the user opens the last node in my structure.
    I checked the events available in the class , but there in none which gets trigered when we try to open a node.
    Please guide me with this scenario.
    Thanks & Regards,
    Omkar M.

    Hello Omkar
    The solution is somewhat odd but apparently works. As sample report please check BCALV_TREE_SIMPLE_DEMO.
    Copy this report and make the following changes:
    class lcl_tree_event_receiver definition.
      public section.
        methods:
        on_expand_no_children " new event handler method
          for event expand_no_children of cl_gui_column_tree
            importing NODE_KEY,  " class = CL_GUI_COLUMN_TREE !!!
        on_add_hierarchy_node
                  for event on_add_hierarchy_node of cl_gui_alv_tree_simple
                        importing grouplevel
                                  index_outtab.
    endclass.
    CLASS lcl_tree_event_receiver IMPLEMENTATION.
      METHOD on_expand_no_children.
        BREAK-POINT.
      ENDMETHOD.                    "on_expand_no_children
    FORM register_events.
    * define the events which will be passed to the backend
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
    * define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      APPEND l_event TO lt_events.
      CALL METHOD tree1->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
    * set Handler
      DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
      CREATE OBJECT l_event_receiver.
      SET HANDLER l_event_receiver->on_add_hierarchy_node
                                                            FOR tree1.  " CL_GUI_ALV_TREE_SIMPLE
      SET HANDLER l_event_receiver->on_expand_no_children
                                              FOR ALL INSTANCES. " CL_GUI_COLUMN_TREE !!!
    ENDFORM.                               " register_events
    As soon as you open a node in the ALV tree the report will stop at the break-point.
    Now you need to check if there are still children nodes to be displayed.
    If not then trigger your special coding.
    Regards
      Uwe

  • Where can I find an event handling for non gui purposes good tutorial

    Hello to all, I am searching the net for a good tutorial about java Event and Event handling that is not GUI related.
    All I find on the net are tutorial and examples that are related to GUI components the has pre defined events and handlers.
    please help me find good material to learn from.
    Appreciate it a lot.
    Dan

    I'd say goto the Java tutorial (www.thejavatutorial.com) and check up from there. Just because most event handleing is done in GUI's (swing comes to mind) doesn't imply its limited to that. For an example, check out the JavaBeans trail. Beans have ways to communicate with each other when (for example) a change in the bean occurs. Thats done through an event yet isn't related to GUI's in any way.

  • Event handler switch creation (for repeated use )

    Im creating a hyperterminal like application which reads from serial port and  writes into serial port.
    The reading and writing works almost fine..I also wants to create some custom "Key controls" that will send some prestored commands to the serial port.
    I currently implemented two commands "ESC" and "FLASH " in the Key controls menu..
    I want to send these commands ESC and FLASH each time i click a button in the menu.
    I used event handler for it..and put the event handler inside an always running while loop.
    But the problem is I can send only these commands only for one time during execution.
    Repeated pressing of switches doesnt cause any effects..
    Can somebody help please???
    Im using labview 6.1. If u modify VIs using higher versions i cant open here..kindly include a jpg screenshot inthat case.
    Thanking you.
    Stephen.
    Attachments:
    Serial Port(stable release)1.2.vi ‏113 KB
    Init.vi ‏32 KB
    Write.vi ‏44 KB

    Hi Stephen,
    in LV7.1 your events will be executed whenever I press one of the according switches...
    Notes:
    -Don't make several event structures. Instead make one event structure with several event cases. Read the context help for the event structure!
    -I would suggest to set the mechanical action of both switches to "latch when pressed" instead of "switch..." to give a feedback to the user as the switch will be reset after reading it...
    -Generally be more styleguide-conform! Use right-click on terminals to create controls/constants to avoid coercion dots (spot the red colored dots in the image?). Make error in/out in the lower left/right of the connector pattern. Avoid block diagrams larger than the screen (or what kind of monitor do you use?).
    Edited:
    Sorry for weird display. I have to get used to the new image gallery feature of the forum (and will use "image to the left" only on rare conditions). Btw. the preview looks different to the actual post
    Message Edited by GerdW on 05-28-2009 06:59 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Migration from Serial polling to Serial queue with event handler

    Hi, I am trying to migrate from classical serial polling communications to serial queue with "event handler" for the buttons pressed by the user. I have placed four while loops, one for the event handler, a second one for serial reading, a third one for serial writing (depending on what button was pressed) and the last one for processing what was read from the serial reading while loop, via a queue.
    My attached device reads the signals from 8 sensor ( 4 temperature and another 4 temperature plus humidity in the same sensor ) and send them via serial to Lavbiew.
    First of all, only once just after running the LV program, I must turn on my attached device with an ON command plus a carriage return after that the device will respond with the number of sensors plugged to it, disabling the corresponding buttons in the front panel. Then labview must wait until I pressed Acquire Button (event handler) and send a CF command plus what sensors to acquire plus a carriage return, then the device will respond continuously to labview with the sensor readings until I press the stop button (event handler), there is also another button to exit the program, also with event handler.
    I am having problems using the event handler and the queues because I am new using these structures, I have looked at  the LV examples but there is nothing concrete on using serial with event handler and queue.
    Take a look at my VI and you will soon notice what kind of problems I am having, any suggestions will welcome.
    Thank's in advance.
    Regards.
    Attachments:
    serial queue.zip ‏76 KB

    Hi Luisete,
    Maybe the problem arise because you are En- and DeQueue in parallel. You do a lot of things in parallel, that is nice if you are sure that one loop doesn't have to wait for another loop. Make sure you don't dequeue before enqueue.
    Hope this helps
    I never knew that the standard error cluster output could be wired directly to the loop control of a while loop.
    First time I see this

  • Multiple events handled in a case, variant type newval

    Hi!
    I use an event case structure, and one case handles two value change events. One is a button's, the other is a cluster of controls'.
    I would like to distinguish, whether the source was the button, or one of the controls in the cluster, but i get back the new-val and old-val in a variant type.
    How could i get the appropriate values back?
    Thanks 
    Solved!
    Go to Solution.

    For this, you would use the "ctlref" event terminal, not the "newval".
    If you only have two controls, create a control reference for one and compare it with the ctlref event terminal. If they are equal, that was the control, else the other one. Place the terminal of both controls inside the event to get the values of each.
    (If you have more than two controls, create an array of control references and use "search array" for the ctrlref output)
    If your controls have unique names, you could also use the ctlref to get the control label, for example. 
    LabVIEW Champion . Do more with less code and in less time .

  • Mouse click on graph without event handling

    Is there a way to detect mouse click on a graph without the event handling? My base version of LabVIEW does not have event handling features.
    Thanks,
    Ryan
    Solved!
    Go to Solution.

    Leaving out the Event Structure seems like cruel and unusual punishment.  My scorn is divided about 80/20 between NI for selling it and whoever tried to save a few bucks by buying it and then sticking it to you to workaround.  Perhaps you are a student in which case you are free labor and it is all good.
    Maybe your boss is a purist and dislikes Event Structures because they break the dataflow paradigm.  The alternative is of course polling, and in this case you have plenty of data flowing!  Unfortunately 99.9% of it is worthless.  Here is a little example in LV8.2 (don't know your version) that uses polling to check on the mouse button.  I only added a simple check for the button being pressed, if you want to know click (down/up) you can add a shift register and look for transitions in the button.  I do check that the front panel is up front, otherwise it will still register clicks even though you may be surfing the web.
    Hopefully everything is in the base package.
    Attachments:
    MouseClickNoEvent.vi ‏26 KB

Maybe you are looking for