Event Structure Question

Hopefully I can explain this okay....
I'm using an event structure to control several features in my program and all have worked great.  All of the events in my program are handled via boolean buttons with value changed option.  I have a numeric control in my program that controls integration time.  This changes when the user clicks the up or down arrow or types in a new value.  This control is used and needed to changed the integration time in a couple of different event cases.  However now I'd like to use this numeric control (integration time) to not only change the integration time but also trigger one of the events (in addition to the normal button that I have been using to trigger the event I need to have happen).  (The value of the numeric control when changed also executes a case structure when it is changed in one of the other events.)   
However when I tried to do this, I ran into some problems.  If I change the numeric control value during one of the events in which I need to use it, and after stopping the event, then another event seems to execute (based on the changing of the numeric control, this event is the same event I ultimately would like to trigger).  Basically I need to stop the numeric control from executing after stopping another event when its value has been changed and only executing when I need it to.  Everything I seem to be doing hasn't been working and I'm just not seeing any type of walk around.  But I need to be able to use the control in various events to change the integration time and also if needed to change it and thus trigger an event (besides using a boolean button to trigger the same event). 
If needed I can post screen captures or sample code, but my main vi is rather large, so I'd have to cook something up as an  example.
Any help provided would be much appreciated.   
Using Labview 7.0 and 2010 SP1 with Windows XP and 7.

The attached amusing example is an architecture which will work for you.  Read the documentation for details.  It has two components - an event hander and a task handler.  The event handler is the LabVIEW event structure.  The task handler is the queue-based outer loop.  If you need to add data to the tasks defined for the queue, make the queue element a cluster and add a variant to it.
As a general rule, most UI projects involve getting to the same task through different events, making this the standard design pattern for almost any UI driven program.  You can separate the task handler (consumer) and the event handler (producer), but I have found that the synchronization problems are not worth it.
I posted 7.0 and 7.1 versions of the code.
This account is no longer active. Contact ShadesOfGray for current posts and information.
Attachments:
LargeGUIApplicationsInLabVIEW_70.zip ‏735 KB
LargeGUIApplicationsInLabVIEW.zip ‏711 KB

Similar Messages

  • LabVIEW 7.1: menu driven event structure question: How can I cause an event case to fire when either a boolean object or a menu item is selected without polling?

    I am using an event structure to eliminate the overhead associated with polling from the GUI. I have build cases associated with each front panel button, and would like to programmatically generate a menu for the vi, adding each selection from the menu to its associated case. However adding a "user event" to a case that is already associated with a front panel button does not seem to allow the selection of the associated user event. Do I have to register each option on the custom menu? Should I programmatically generate the menu and use the same array to register the choices? Are there any examples out there
    that would help me?
    Thanks!!!!
    Steve

    Hello:
    I visited the forum for the purpose of getting some ideas on user
    events architecture. Well, I have to finished standalone working
    modular VI codes one which works as a standalone local control and
    one  which works on a remote communications mode. Now these 
    codes in themselves has event driven capabilities my problem is I
    needed to create another topmost layer VI that will be capable of
    switching between these remote and local operating mode - which I was
    thinking also to be event driven. This maybe a poor idea but I tried
    anyway. Is the User Event loop can be nested? Meaning an event within
    an event thing?
    Regards,
    Berns B.
    Bernardino Jerez Buenaobra
    Senior Test and Systems Development Engineer
    Test and Systems Development Group
    Integrated Microelectronics Inc.- Philippines
    Telephone:+632772-4941-43
    Fax/Data: +632772-4944
    URL: http://www.imiphil.com/our_location.html
    email: [email protected]

  • Event Structure Questions

    Is there any other benifits to keeping the control insid ethe event OTHER than being able to double click the control on the front panel to gain instant access to teh event that hold the code for the control event.
    What is the best way / type of event for buttons that are latched until released?
    I have had issues in the past with using "value change" type events that results in the operation being ran twice.  Once when the button is pressed and once when the button is released.  Does placing the control inside the event stop this?
    To prevent the dual code scenerio I have switched to "mouse down" events but have had times when the code was ran even when the control was disabled, but because a mouse click was detected it still ran the code.  To prenet this I have added a property node value check case inside the event to ensure the code is ran only when the value of the control is in the correct state.
    How are these problems avoided with events?
    Thanks
    Tim C.
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!

    dan_u,
    that's not correct, as any other control might be read before a value change event fires (placed on the left hand side of the event strucutre), thus processing the event with the Old data.
    Felix 
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Questions from a rookie about event structures

    Hello,
       I am currently scheduled for Labview classes next month,
    so I want to apologize in advance for "dumb questions". I have created
    a program that is starting
    to be a CPU resource hog. The majority of my program is inside a while
    loop so that the program will "react" to changes in controls, etc. I am
    assuming that
    if I incorporate "event structures" in my program that my program will
    not be a resource hog.  Is the use of event structures the correct
    way to go? If using
    event structures is the correct way to go, what is the best way to
    learn how to incorporate "event structures"?  I am assuming that
    the examples in Labview will show me how. Are there any good reading
    materials about event structures?
    Regards,
    Kaspar

    To fix the CPU resource issue, you need to place a small wait statement in your loop. It will solve two problems:
    Slow down the loop (you don't need to check for UI changes more that 10x/second)
    It will allow other, parallel tasks a chance to run after each iteration. Without a wait, it will hog the CPU for 55ms before releasing control.
    If your loop currently spins one million times a second and you would place a 1ms wait, the CPU would go from 100% to 0.1%!
    The event structure is a fantastic tool to solve most UI issues and it makes the diagram automatically simpler, more self-documenting and easier to read. Have a look at some of the examples that ship with LabVIEW.
    The event structure is easy to learn, so dive right in. Read the online help for some important considerations. As a rule of thumb you should stick to a single event structure per diagram.
    LabVIEW Champion . Do more with less code and in less time .

  • Event structure input event question

    I'm using a state machine to do some data decoding stuff. The default initial state is Idle, which checks an output boolean value from a FIFO buffer. If the boolean value is True, go to the next state; otherwise, keeps waiting. See attached "idle_noEventStructure.vi" for part of the code. But this method will consume a lot of CPU usage.
    In order to save CPU time, I try to use an event structure in Idle state to wait for the output boolean value change. But I don't know how to add an event for the boolean value change. See attached "idle_eventStructure.vi".
    Any one could help?
    Thanks.
    Attachments:
    idle_noEventStructure.vi ‏7 KB
    idle_eventStructure.vi ‏8 KB

    MileP,
    First off, in the state machine example you give "idle_noEventStructure.vi" the reason you may be experiencing poor performance (high CPU) is that your while loop is running as fast as the OS will allow sicne there is no timing implemented.  You should always you a "wait" function inside the loop (see attached file).  The loop should only run as fasat as you need to check the FIFO for new data.
    If you want to use an Event structure you can use dynamic event registration to create an event for the FIFO data.  I have outlined this in the attached code.  It may not be eactly what you need but should give you he right idea.  An event is created for the boolean output from the FIFO and this event is registered with the event structure.  I am simulating the FIFO data using the "Producer Loop" and the Trigger control.  I am simply stopping all the loops when the Trigger button is pressed, but this is done using the event creation.  This method still requires a polling loop ("Consumer Loop" in my example) to check for FIFO data, but the lopp rate can be handled more carefully this way.  And I am not sure there is anyway around using some method of polling.
    Dan
    Attachments:
    Event Registration.vi ‏17 KB

  • Question regarding event structure

    I made a vi that controls a stepper motor with controls such as relative angle, maximum frequency, and acceleration. I use an event structure to update the values after new ones are entered by the user. However, recently I was given the task of integrating this with a larger vi that controlled other parts for an experiment (I will refer to this as the motor control vi). 
    Would event structures in both vi's be necessary? If I want to have the controls and update button in the motor control vi, does this mean that the event structure should be completely eliminated from the stepper motor vi? I was advised to use local variables to store the values for relative angle, max freq, and acceleration and then pass all of it when the update button is triggered and creates an event. I have found this to be faulty. Would it be possible to have event structures in both vi's then? 
    Basically, now everything will be updated and passed from the main vi to a stepper motor vi that originally depended on an event structure. Does this require the event structure to be present in only one or both vi's? Thanks.

    Hey, sorry for not including it before, I'll try my best to explain all the parts because I didn't want to overcomplicate things.
    For the Stepper Motor vi, I have none of the DAQ drivers on my laptop at home so I excluded it in the file attached and simply put a text box in there place. The program starts after the run button is pressed, and then the acceleration, f max, and relative angle is entered. Afterwards, pressing update displays the appropriate waveform graph. Pressing "next task" (depending on the state of the use task button) will allow the user to input other values. The use task button simply indicates whether anything will be passed to the drivers or not.
     The main Motor Control vi was done by another person. For my part (all on the right side), acceleration could be set to 3 different speeds and pressing the button triggers the event that sets a certain value to the local variable acceleration. When the update button is pressed on this vi, the new values for max speed, angle, and acceleration are sent to the Motor Client vi. The state of the run, stop, use task, and next task are also passed, and my current problem is how do I use the update button in this vi? Would passing its value create an event in the stepper motor vi? Or would it be much better to just send the controls without placing them in an event structure?
    Attachments:
    Motor Interface.vi ‏60 KB
    Stepper Motor.vi ‏33 KB

  • Daqmx "Done" event not triggering event structure

    I would like the user to be able to abort my daqmx task by pressing a button.
    I am attempting to use the method in this VI:
    https://decibel.ni.com/content/docs/DOC-15815
    It utilizes an event structure with the daqmx Control Task VI to abort.
    The example VI above works for me, on my system with my USB-6356 device, as expected.
    When I attempt to incorporate the same method into my VI it does not--despite having an identical arrangement, so far as I can tell.
    I believe that my problem lies with the event structure, and the dynamic registration.  I am unfamiliar with this and must be using it incorrectly.
    I have attached my VI, though it is cumbersome.  The code which I am struggling with is in the "Acquire" case.  As far as I can tell, I am doing exactly the same this in this particular case as in the example mentioned.  Yet in the example, the event structure completes, or aborts, whatever you want to call it, right after the "Wait Until Done" VI executes.  In my own VI, the "Wait Until Done" and "Clear Task" VIs execute, but the event structure does not register it.
    Here are my specific questions: is there anything extra or special that one must do in order for the Task to properly trigger a "Done" event and pass through the event structure?  At what point is the daqmx task "Done"? 
    thanks,
    Matt
    Attachments:
    BoomTubeMain.vi ‏175 KB

    natasftw,
    My event structure is identical to theirs; what you are seeing are the two different cases that exist in the event structure.  In both the example and the VI, there is a <task out>: Done and a "Dynamic Event": Value Change.  In the dynamic event case, I have my abort button and relevant code--this I believe is the code you were referring to, which you thought I was missing...  Regarding my multiple event structures, they should operate completely independently as they respond to different events.

  • 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 can i use the same front panel graph in more than one events in an event structure?

    i want to display the signals from my sensorDAQ in a graph.but i have more than one event in the event structure to acquire the signal and display it in the graph.the first event is to acquire the threshold signals and its displayed in the graph as a feedback.after the first event is executed, i will call the second event,where the further signals are acuired and compared with the threshold signals from the event 1.my question is how can i use the same front panel control in more than two events in the event structure?please answer me i'm stuck.
    Solved!
    Go to Solution.

    Hi,
    I have attached here an example of doing the same using shift registers and local variables. Take a look. Shift register is always a better option than local variables.
    Regards,
    Nitzz
    (Give kudos to good answers, Mark it as a solution if your problem is Solved) 
    Attachments:
    Graph and shift registers.vi ‏12 KB
    graph and local variables.vi ‏12 KB

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

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

    Hello,
    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.
    Vaibhav
    Attachments:
    terminate event_diagram.jpg ‏200 KB
    terminate event_front_1.jpg ‏63 KB
    terminate event_front_2.jpg ‏63 KB

  • How do I access indicators in other windows of an event structure?

    Let's say I have an indicator in 'case 1' called ON/OFF.   How do I get the status or value of ON/OFF if I'm in case 2?
    or - if this seems like a ridiculous question, am I missing some sort of important concept about how event structures work?
    thanks
    -z

    Local variables are certainly an option.  Property nodes are another, but both of which are probably the least recommended around here.
    You can use shift registers, but then you have to be careful about where you update your indicator.  Unless you've got a ton of these that need updating, that's the way I'd go.
    Place your indicators outside the event structure and then just make sure you wire everything through every case (otherwise you'll end up with the default value of your indicator's type).  See the image...  I think it's more clear than my words can be.
    Message Edited by Will.D on 10-31-2006 04:16 PM
    Attachments:
    Update.jpg ‏18 KB

  • Handling windows messages within an event structure

    Hello all.
    I've got an event driven VI which makes use of an event structure. I'd like my VI to be able to respond to some custom windows messages (i.e. WM_USER) sent from a separate process that listens on a telemetry card (sends a message when it receives data).
    I have tried modifying the Windows Messaging Queue VI example provided by NI so that the VI will process windows messages during the timeout event in the event structure but this doesn't seem to work.
    Any suggestions?
    If labview events and windows messages don't mix then I guess I could do away with the event structure and go entirely with windows messages. This could be done by defining some custom messages that replace the labview events (e.g., W
    M_STOPBUTTON_PRESSED = stop button, value changed event) and have the VI post these messages using PostMessage from User32.DLL and then catch these messages in the same manner as the NI Windows Messaging Queue VI.
    My preference is to make use of the event structure if I can because its more inline with the labview methodology.
    This is really interprocess communication question so if there are other ways of achieving the same result (sockets, named pipes, shared memory?) I'm keen to listen.
    cheers,
    Novak.

    These 'sockets' sound interesting. What exactly are they? Could you direct
    me to an example?
    Thanks
    Denis
    "VI Guy" wrote in message
    news:[email protected]..
    > LabVIEW Events and Windows messages don't mix. To implement as such,
    > you would have to do as you describe.
    >
    > Using sockets as an inter process communication scheme works great.
    > And on a single machine, they dont leave the computer (i.e. no round
    > trip on the network). Also, its cross platform compatable, not to
    > mention it adds the possibility of being able to seperate your
    > processes across several machines. Add to this that sockets are as
    > easy to code as serial communication (with the benefit of "sleeping"
    > waits instead
    of "serial polling") and you get a solution fits many
    > applications and needs.
    >
    > Get the idea I am sold on sockets?
    >
    > Good luck.

  • Load defaults from file with event structure in vi

    Hi All,
    I've been trying to figure out how to do this but have not quite got there. Taken a look at lots of posts but can't quite find the answer to the question that i've got.
    I've got a vi for controling 4 PCI cards making calls to some DLL's. I've got quite a number of controls on the FP and i use an event structure to update the values on calls to the DLL. On startup, one of the first calls that i make is initalise and that sets the cards up. I then want to load my own set of default values from a file to initalise the cards to my particular set up. While the software is running the user may change the values and wish to save a file with the new default values, or he may wish to load a different file of default values (depending on the test that he is running). I've got the Control Values:Get All [variant] and the Control Valueset [Variant] working to save all the controls values to a file and read that file in and set all the controls values. So far so good. Problem is i'm using an Event Stucture and it doesn't register that the values have changed. I could complish this by using Value(signaling) but the data from the Control Values:Get All is variant data and the Value(signaling) needs the same data type as the control. What do i do?
    One thing i have thought about is to write all the values from the file to all the conrols and then have a read Value and a write Value (signaling) to trigger the events. Problem is i don't want to set this up for every control (it'll take me ages). Can i do it programitically? Is there a better way to do it?
    Thanks,
    Phil

    You could create a boolean control/indicator and signal that value when you've updated the values on the FP.
    Name it something like "update FP". The event case for that boolean will have the code to update the necessary parts of the FP.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • Maximum size of an event structure

    I have just a short question about the maximum size of a event structure, and did not found it yet in the forum.
    I have an event case with 35 event cases. How many are allowed, what is recommended and is there a huge loss of performance by seizing it up?
    Thx for answer

    As far as run-time performance is concerned, the number of event cases in an event structure should have no noticeable effect.  Worst-case scenario, when the event structure is woken up due to an event occuring in the system, it does a linear search through the list of event cases to figure out which event-handling diagram matches the event that it pulled off the queue.  These tests are pretty quick (3-4 comparisons per event-handling diagram) so I can't imagine it really would have any effect on performance.  However, this does tell you that if you want to squeeze every ounce of performance out of your event-handling code, make sure the most frequently run event-handling diagram is the first one in the list.
    The only performance issue I could see arising is what Damien mentioned - at edit time, it may take longer to make edits to the event structure (eg adding new event cases, changing the events a given diagram is associated with).  I don't know that I've seen any issues because of this (the largest application I've written has an event structure 40 different event-handling cases), but I think this is where any potential performance issues reside.
    Hope this helps.
    J
    Jason King
    LabVIEW R&D
    National Instruments

  • How to implement boolean comparison and event structure?

    Hello all,
    I'm currently developing an undergraduate lab in which a laptop sends out a voltage via USB-6008 to a circuit board with an op-amp, the voltage is amplified, and then sent back into the laptop. The student is going to have to determine an "unknown" voltage which will run in the background (they can do this by a step test, graph V_in vs V_out and extrapolate to the x-axis).
    Currently, I have two loops that are independent in my VI. The first loop is used to "Set the zero." When 0 voltage (V_in) is sent out of the laptop it returns a value around -1.40V (V_out) typically. Thus, I created the first loop to average this value. The second loop, averages the V_out values that come into the laptop as the V_in numeric control changes. Then I take the "set zero" value from the first loop and subtract it from the second loop average to get as close to 0V for V_out when V_in is 0V.
    The problem I'm facing is, the event structure waits for the V_in numeric control value change, but after "SET ZERO" is pressed, if there is an unknown value, it will not be added to the average for V_out until V_in is changed by the user. So, I tried implementing a comparison algorithm in the "[0] Timeout Case." This algorithm works for step tests with positive values for V_in, but there are two problems.
    1) Negative values cannot be used for V_in
    2) If a user uses increasing positive values for V_in there is no trouble, but if they try to go back to 0, the value change event has been called and it is added to V_out as well as the timeout case.
    Sorry for the extremely long post, but I've been banging my head over this and can't figure out how to properly implement this. I'm using LabVIEW 8.0.
    Attachments:
    Average Reset Test.vi ‏371 KB

    OK you have bigger problems than Raven's Fan is pointing out.
    When the first event loop stops ( after pressing "") (the boolean text is "Set Zero")  The second loop may start- (AND PROCESSES all of the events it was registered to process before the loop started!)  that would enclude the value change event from "" (The boolean text is Stop) Being pressed bebore the loop started.  Of course, since the labels of "Set Zero" and Stop are identical nulls....................................................BOTH event trigger at the same time and are processed as soon as the event loop they are registerd to is available.
    Get it ... The two buttons labeled "" both queue Value change events to both loops registered to act on the value change of the control labled ""!
    Both loops will do what you programmed in the case of "" Value Change!  This can, (as you have observered) lead to confusing code actions.
    Do avoid controls with duplicate labels (There is a VI Analizer test for that!)  Do avoid multiple event structures in the same hierarchy. 
    DO NOT bring this to your studients to help you learn LabVIEW!  We get enough studii asking embarassing questions
    VI Analizer will help you provide sound templates.  If you need help with that hit my sig line- e-mail me and I'll always be willing to help.
    Jeff

Maybe you are looking for

  • [Solved]External HDD only mounts as read only

    Okay, I have a general log, but I'm not completely sure what all information you need. Ask and you will receive. So I run udiskie through i3, works great, but my file systems get mounted as read-only, which is..not great. It's pretty irritating. So I

  • Possible bug in 1.2.x firmware?

    I have a 30 GB iPod Video, and since updating to Firmware version 1.2.0, and recently 1.2.1, the iPod stops charging once it is ejected. Once the iPod is ejected it returns to the menu, and is useable, but no longer charges, even thought it is still

  • Using ejbc command

    hi, am pretty new to EJBs and am using weblogic 7.1 i had compiled my java files and created jar file now when i run the command ejbc from my dos prompt it says 'ejbc' is not recognized as an internal or external command, operable program or batch fi

  • IPhoto slideshow - how to mute all videos?

    Hi there I've put together an iPhoto 11 slideshow to be displayed during a party.  This includes photos and videos.  However, since this is really a background type thing, rather than the focus of the party, I don't want the audio from the videos to

  • FILESPERSET

    Hi, in 8.1.7 how should I use FILESPERSET for RMAN ? How can I put it in : run { backup format 'C:\backup\myDB\df_%d_%T_%s_%p' database; Thank you.