Usage of Events over Case Structure

Hi,
I want to Know what are the advantages if using Events over case strutures.
Is memory useage less in case of events.
With regards,
Suresh Thangappan
Suresh Thangappan

Hi Suresh
I think you can't just compare these two structure types, as they have a different purpose.
I assume you're about to create an application, so I'd suggest you to study the producer consumer design pattern. There are both of these structures used to separate program-logic and reaction to user-inputs.
Thomas
Using LV8.0
Don't be afraid to rate a good answer...

Similar Messages

  • Event in case structure

    Dear all,
    I am using Event Structure in a Tab Control.
    On page 1, there is a Table Control and when the mouse is clicked on it, it returns the Cell Value. The event is working ablsolutely fine, but the problem is i have no idea how to Stop the Event.
    I am attaching my Vi here. Pls have a look at it and let me know of a possible solution.
    Thanks,
    Ritesh
    Solved!
    Go to Solution.
    Attachments:
    Event in Tab.vi ‏18 KB

    ritesh024 wrote:
    But, it means that the Events in Page 1 are getting triggered even when the Control is on Page 2.
    That would take the unnecessary memory and time as there is no need for the events on Page 1 to run when the Control is on a different page.
    No, the event will not get "triggered", because if you are on the other tab it is impossible to fire the table event and a mouse up cannot occur. The event structure is in memory no matter what and placing it inside a case structure only complicates the code and can will lead to problems.
    The event structure should always be in the dataflow, the tab position is irrelevant. Never hide an event structures inside a case structure!
    Here's a quick example (LV 8.5). Tab 1 has your table and senses the cell position. Tab 2 has a light switch. As you can see there is no case structure needed.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Event_in_TabMOD.vi ‏19 KB

  • Start event from case structure

    I'm running my main programm inside an event of an eventstructure.
    Beside this main event I additionally have 3 other events in this event structure.
    To save "screen space" I would like to start indirectly one of my other events from a case
    placed inside another event.
    Is this possible - would be glad if you have an example.

    You are still completely misunderstanding the purpose of the event structure (see also my answer the other thread).
    The main code of the program does NOT belong inside an event structure. What good is an event structure if it is tied up indefinitely inside one of the event cases???
    An event structure is most useful for dealing with interactions by the user and must be ready to handle those at any time. It is not a tool to "save screen space" (whatever that means). If you are running out of diagram space, consider wrapping your code segments into subVIs.
    LabVIEW Champion . Do more with less code and in less time .

  • Event structure vs case structure?

    I am developing an application that is fairly user input based... lots of boolean control buttons to do different things.
    In the past, I have avoided "value change" event structures, and instead went with a while loop, stacked sequence, and series of case structures. After having done it, I decided this was a terrible idea. This time, I intend to build an array from the booleans, convert it to a number, and feed it in to a single case structure. This will give me the option to add cases for different combinations of the booleans being pressed.
    I guess the question is: What is the best method for doing something like this?  Does one have advantages over the other?
    Edit: I wasn't that clear.  I would like a comparison between the "value change" event structure method, and just feeding everything in to an array -> case structure.  I also am worried that with the bool array -> case structure that I will run in to problems where I end up with too many control variables, and the value of the resulting number gets ugly very quickly. The application has several buttons... next, last, save, load, several different configure setup buttons etc.
    Thanks!
    Solved!
    Go to Solution.

    Aalenox wrote:
    I am developing an application that is fairly user input based... lots of boolean control buttons to do different things.
    In the past, I have avoided "value change" event structures, and instead went with a while loop, stacked sequence, and series of case structures. After having done it, I decided this was a terrible idea. This time, I intend to build an array from the booleans, convert it to a number, and feed it in to a single case structure. This will give me the option to add cases for different combinations of the booleans being pressed.
    I guess the question is: What is the best method for doing something like this?  Does one have advantages over the other?
    Edit: I wasn't that clear.  I would like a comparison between the "value change" event structure method, and just feeding everything in to an array -> case structure.  I also am worried that with the bool array -> case structure that I will run in to problems where I end up with too many control variables, and the value of the resulting number gets ugly very quickly. The application has several buttons... next, last, save, load, several different configure setup buttons etc.
    Thanks!
    Event structure. Among other things, it will allow your loop to "sleep." then wake up when an event happens. With a case structure it's going to be constantly polling. Event structure is pretty much always the right way to go in newer versions of LabVIEW that have it available. I assure you, your first solution was aboslutely wrong and you noticed that, your second is better and was common the way before event structures existed, now that event structures exist, you should go with those.
    CLA, LabVIEW Versions 2010-2013

  • Event structure or case structure

    I have some case structures wired to buttons.  When each button is true, code inside the corresponding case structure executes.  `What are the advantages/disadvantages of using an event structure instead of a case structure?
    Ron Deavers, CLD

    Place an indicator for the iteration terminal of the main loop to see an obvious difference
    Your case structures must be in a loop that constanty runs. If you don't put a delay in the loop, it consumes all CPU, but if your delay is too long, it takes a moment to react to the button changes. The loop spins all the time, no matter if you press buttons or not.
    Your event structure also sits in a loop, but nothing happens until you press a button. Now the event structure triggers IMMEDIATELY, executes the event case, and then waits for the next event. The loop does not spin unless needed.
    You can even mix the functions by using a timeout event. Code in the timeout event occurs at regular intervals, but at any time, any of the other events can take over.
    LabVIEW Champion . Do more with less code and in less time .

  • Transfering a case structure to event structure

    Hi, I am trying to transfer case structures that are currently set up to a control that if on prompt the user where to save and then save all following files to that location till end of program and if off the do nothing. I would like to enable these to be switched on and off at any point and know to use an event structure. The problem is I am new to coding with an event structure and have been able to get the button to work but not continuously save. I attached a screen shot of the original case structure and was wondering if someone could show me how to change it to the event structure format with the same functionality. I'm getting a little lost and confused. Thanks!
    Attachments:
    alltruecases.jpg ‏534 KB

    I can't attach the vi due to the size and I do not think a simplified piece of code is going to help. I did however go through and stitch two jpegs together of the main two sequences. hopefully this gives a better idea of what I am trying to do and where to go from here. thank you.
    Attachments:
    1.jpg ‏669 KB
    2.jpg ‏317 KB

  • Case structure & event structure

    1.What are the disadvantages of case strucure?
    2.What are the advantages of event structure?

    Are these test questions? I could name 10 for each, but why are you asking?
    While there are often many ways to accomplish the same thing, Case structures and Event structures serve different purposes. Straight from the Help file:
    Case Structure
    Has one or more subdiagrams, or cases, exactly one of which
    executes when the structure executes. The value wired to the selector terminal
    determines which case to execute and can be Boolean, string, integer, or
    enumerated type. Right-click the structure border to add or delete cases. Use
    the Labeling tool to enter value(s) in the case selector label and configure the
    value(s) handled by each case.
    Event Structure (Not in Base Package)
    Has one or more
    subdiagrams, or event cases, exactly one of which executes when the structure
    executes. The Event structure waits until an event happens, then executes the
    appropriate case to handle that event.
    Right-click the structure border to add new event cases and configure which
    events to handle. Wire a value to the Timeout
    terminal at the top left of the Event structure to specify the number of
    milliseconds the Event structure should wait for an event to occur. The default
    is –1, indicating never to time out.

  • Event structure inside a case structure

    Hi,
    I've got a problem w/ my porgram, and managed to boil it down to this
    simple example.  The program basically hangs if you change the
    Numeric value when the boolean is false.  I don't understand
    why.  I suspect it has to do with the way event structures are
    treated, but if someone cou please explain this I'd be greatful.
    Also, now imagine I have 7 numeric controls, handled by 7 cases in that
    event structure, and I actually want to do things in response to the
    value change for each.  Can someone suggest an elegant way to do
    that?  I thought what I had here was a good design, but apparently
    not.
    Bjorn
    (I'm using labview 7.1)
    Attachments:
    EventInCase.vi ‏24 KB

    It is generally a bad idea to place event structures into cases. Events structures need to be able to breathe.
    Maybe you can redesign your program and place the case structure inside the event structure, for example? (Also have a look at the online help for the event structure, especially the link "caveats and recommendations for using events ".)
    Detailed analysis:
    Your event case for the numeric is set to "lock front panel until event completes".  If you change the numeric while the case is false, the evet structure cannot execute, so the front panel locks forever. The observed behavior is as expected. All clear?
    In addition, if the case is false, the main loop spins at nearly infinite rate, consuming all available CPU. Place a small wait to be more cosiderate to everything else running on your rig.
    LabVIEW Champion . Do more with less code and in less time .

  • How can I determine whether to use an event structure or a case structure?

    I'm starting a large project and need a state machine. I can't decide on whether to use a case structure or event structure. Is there an article  or other information that describes criteria for selecting between the two approaches?
    Thank you,
    Chuck
    Solved!
    Go to Solution.

    Hi Chuck,
    Well case structures and event structures differ quite alot.  Here's a link for indepth information on Event Structures, and using them in state machines: http://zone.ni.com/devzone/cda/tut/p/id/2962.  Hopefuly this will help you make up your mind.  
    Let me know if you have any questions after reading it. 
    Regards,
    Dominic Walker
    Cardiff University
    Electrical and Electronic Engineering Student

  • Case structure/event counting

    Thanks so much everyone for your help. I was
    able to get it to work. I now have a second question that I have been
    wrestling with on my program for some time. I am hoping to be able to
    count the number of times each event happens, be it >0, <0 or 0.
    So far, I haven't been having a lot of luck on figuring this out.
    The
    way my program works is that the case structures control the opening of
    solenoid valves. I am running a while loop to keep the program running,
    but would like to be able to at least count the number of times each of
    the cases are true in an effort to figure out the amount of time each
    of the solenoids is open during a run.
    What I really need
    to do is be able to run each case for a maximum of 10 minutes each, and
    then stop the case from running. I know this is an in depth problem,
    but simply counting the number of times each of the cases run would be
    a huge start for me.
    Thanks again for the help on the other problem.
    Tim

    You need three different counters, one for each event. Right now you increment the same number, irrespective of case, so you might as well do this outside the case structure or even just use the iteration terminal. Also, the counter should be blue (I32). You also need to initialize the shift registers.
    Here's a simple example (LabVIEW 8.0) that uses an array of three elements to keep count of the three cases. See if this makes sense.
    Message Edited by altenbach on 08-27-2008 09:30 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    countCases.vi ‏13 KB

  • Editor bug if you drag a case structure over an index/replace elements node on a in place structure

    To reproduce:
    Drag a case structure over a index/replace array node
    You'll end up with this train wreck. Autocleanup no longer works
    Interestingly, you can still get it to compile but setting the boolean to true doesn't run the true case. Warning: dragging the below snippet onto your block diagram will probably crash LabVIEW
    Select all that and drag it into a new VI. Run autocleanup and the development environment will crash: Exception: Noncontinuable exception (0xC0000025) at EIP=0x00000000
    Running LabVIEW 2014 SP1 with nothing special.

    To quote Obi-Wan
    This is not the bug you are looking for..........
    Now search for "Clear as mud"
    Having a Wired treminal inside an IPE driving conditional code should break the snot out of that code and cause the compiler to puke all over!  The lack of check for that insanity is causing the crash!  Don't do it!  Just think of how you are abusing the poor IPE.  What if you had a breakpoint on the Inplace Boundary and changed the boolean?  That would necessatate a copy inside an inplace structure....... NO!!!!
    Or, more to the point as best I understand: (Add duct tape adound head as needed)
    An IPE must exist in one "Clump"  Terminal Reads exisist in their own "Clump" (although you can read many terminals in one clump)  So you require a clump to read the boolean terminal inside another clump.  Clumps cannot reside in clumps since clumps are clumps that stand apart from each other by definition.  The run arrow should be broken but is not- hence LabVIEW crashes. Makes sence to me  except the clumping algorythm didn't catch the insanity and the run arrow wasn't broken.  so the next edit caused all hell to break loose.
    (If I missed domething here I am going to learn something today)
    Jeff

  • How do I select different graphs to show using case structure?

    Hello,
    I am working on a piece of code where I am getting  data from 6 different sources (reading temperature & pH on 6 different tanks)...  I am using
    1)  a case structure
    2) while loop
    3)  waveform chart
    Now, I want to have it so, the User selects which graph he wants to see (tank 1, tank 2, tank 3, etc...).  And then, program ONLY SHOWS the graph for THAT TANK...
    So I have an Event Structure with the "Tank #" control, which is supposed to change the graph that is on display.  However, right now, it is not working.
    Let's say I start the program..., then I click "Tank 1"...  it graphs Tank 1...  then I click "Tank 2"...  instead of COMPLETLY CHANGING the graph, it CONTINUES to graph the data from TANK 2 on the same graph.  I.E.:   it plots points  1 - 7  from TANK 1,  then plots points 8 - 15 from TANK 2,....  on the same Graph.
    I don't want that.  I want it to change the graph.   But if I put the graph in the Case Structure, it puts multiple graphs on the Front Panel...  How can I do it?
    NOTE:  Ignore case 3.   And each case should be corresponding to Tank #...
    Thank your for reading--
    Attachments:
    GraphProblem_NI forum.vi ‏3166 KB

    the easy answer is that you should clear your waveform graph before sending new data to it...
    It's as easy as writing an empty array to it's property node Value...
    But.. 
    you've got much... much more cleaning up to do.  Clearing the graph is just one thing.
    Your code is unreadable.  Why do you have 3 While Loops?
    What does the bottom one do?
    Why are you complicating things with cluster going into the queue?  An enumerator would do the same trick.
    Is this code going into a cRIO or cFieldpoint?  If not, what's up with using Shared Variables?  Are you planning to send data over the network?
    Debugging this code will become a nightmare.  Scalability will be worse..
    I would recommend refactoring the code while it is still manageable.

  • How to implement Case Structure for multiple inputs to Pic Ring?

    So I have a reasonably simple program which I am almost completeed with. Basically the data of an array is read and then is indexed and a new array is created from the indexed data. And then I use Match Pattern to see if elements in the new array match certain words. And if they do then a number value is allocated to a Pic Ring at the end. And depending on the final number value the Pic Ring changes from one pic to another.
    However, I have the problem that I will be using multiple Match Pattern functions to compare elements in the final array, but I can't attach multiple Match Patterns and their subsequent logic statements to a single Pic Ring, only one. I've been trying to work this out by implementing a Case Structure or Event Structure. But the Event Structure isn't working and with the Case Structure, it is very messy with multiple True/False Case Structures inside of each other. Anyway, hopefully this all makes some sense. I'm attaching the VI program to this post. Thanks.
    Attachments:
    ArrayTest2.vi ‏495 KB
    ArrayTest2.vi ‏495 KB

    Obviously, you can only display one picture.  So then the question becomes which picture to show.  Therefore, you will have to create some sort of preference of one pattern over another.
    I would use a FOR loop so that you can loop through your available patters and their possible results.  Use the Conditional Terminal on the FOR loop so that you can stop the loop on the first match.  Then you just wire up the selected value for the ring outside of the loop.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Enter and exit a case structure

    I'm currently building a control.  I have a condition for three booleans to become true to enter a case structure as true.  One of the conditions is a temporary increase in temperature. I want to stay in the case structure after the temperature becomes false but both of the other booleans stay true. Is there a way to do this or should I be using some other technique?
    Thanks,
    Colt

    I think this guy is running into the same misconception I and many of my classmates ran into about LabVIEW back in the day.  When your code enters the True Case, it will complete the True Case and immediately exit the True Case to complete whatever other tasks that may be outside of the Case Structure (assuming it didn't already do them). Then, the while loop (you must have a while loop) will move on to the next iteration, meaning it will do it all over again.
    Now, if you know already know and understand how code works in general (about iterations) then do forgive me.  I've edited a lot of student code and have seen this very mistake.  A misunderstanding of the fact that code reiterates and will do it all over again if not told to do something else.  Typically the mistake is made with Event Structures.  I know it doesn't make much sense to not understand that...but trust me, it makes sense to those who don't understand.  ha

  • How can I have multiple inputs into the selector terminal of a case structure

    Hi everyone
    I have a question on how to wire multiple inputs in to the selector terminal of a case structure. 
    Currently, I have three switches, each switch determines different case. So if I switch the switch 1 is on, the numeric indicator will show 1. If the switch 2 is on, the numeric indicator will show 2, so on and so forth. However, the selector terminal will not allow me to wire multiply inputs into the case structure, I tried Bundle by Name, Bundle and Array to Cluster, but they did not work. I set the case structure with 3 cases, they are 1, 2 and 3.
    Could someone help me please. I have attach an image and the VI of the work I did so far.
    I have another question, is there a function which can toggle other switches to off when there is a switch has been toggled on.
    Thank you very much
    Tommy
    Attachments:
    Trial - Case Structure.vi ‏7 KB

    Tommy, attached find a cheeseball way of doing this that has given me a LOT of mileage over the years.  IT lends itself nicely to a couple of really good practices that NI recommend, but I have given you the bare-bones to "see under the hood".  
    The recommended practices:
    1. You can make this a nice tight sub-vi where you can put it into a core library of routines that you'll use over the years, even extending the logic to look only for changes, etc.
    2.  If you are thinking about Front Panel design considerations, you'll want to use arrays of controls where possible, as that's a nice neat way of containerizing your switch for both the FP and Block Diagram.
    Have fun.  I have TONS of these types of things, so feel free to PM me if you have any other needs.
    Wes
    Wes Ramm, Cyth UK
    CLD, CPLI
    Attachments:
    Boolean Switch Logic.vi ‏11 KB

Maybe you are looking for

  • I have installed iworks 9 now wont open up, i have installed iworks 9 now wont open up, i have installed iworks 9 now wont open up

    i have installed iworks 9 and tried to open it up and it tells me to purchase serial number but i installed from a cd

  • Sound isn't coming out of the right speaker/headphone

    my ipod has cut off the sound to the right headphone... Thought it was just my headphones but it does it to every pair.

  • FSM Service

    Deployed service in integrated WLS.Previously was getting ClassDefNotFound Exception so put all the required jar file in domain/lib dir and this got resolved. Now when invoking any operation/method at service endpoint i getting the following exceptio

  • Soap 1.1 and 1.2

    Hi all, I have a requirement where I have to expose a bpel process as http service. I used http adapter in services section and deployed in the server.An external caller is calling my service and sending the messages thru http post but i am not able

  • IPhoto won't let me quit !

    iPhoto6 has started freezing on me every time I try to quit. Whether I use the red button or Apple+Quit (iPhoto) nothing happens. Well, the red button get's dimmed, but nothing happens, not even the swirly colour timer. I then have to do a Force Quit