Usage of event structure

Hello everyone,
Is it possible to have an event structure that listens to two events in one case and if those two events for example change, then an action is taken, if only one event occurs then no action is taken? I have four clusters and i trying to setup an event structure that listens to changes. (e.g. cluster 1 & cluster2 change , do something, cluster 1 & 4 changes, do  something different). Is this possible?

smercurio_fc wrote:
You can also accomplish this using custom events. There's an example that ships with LabVIEW called "Programmatical Fire Events" that shows the basic idea. You would create an event that is your cluster1 and cluster2 change, and another that is your cluster1 and cluster4 change. Then you would set your event structure to have one case to handle when this event gets fired.
One thing that is not clear is if cluster1 is changed, and then cluster4 is changed, and then cluster2 is changed, is this two events (cluster1/cluster4 change and cluster1/cluster2 change), or one (cluster1/cluster2 change)? In other words, does an event cancel out a possible event that is "building"?
Well thank you guys for your rapid response. What I am trying to do is have four clusters and essentially i need to determine which clusters where chosen. It could be all four, or three or two, or just one and determine which one it is . Once i know which one it is, i build an array accordingly to the number of clusters chosen and place zeros for the clusters not chosen in my array. I am playing around with the examples and trying to implement a custom event for these cases, but it doesn't seem like this is the best way to go at it.

Similar Messages

  • 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

  • Can you share FP Controls between different Event Structures

    I'm creating a program that will either read real-time data from an VNA on the GPIB bus, or read a saved s2p (Agilent) file and analyze it. The FP consists of 5 graphs, and various controls which handle events like printing, changing filters, or exiting. on the BD I have a case structure controlled by an operator selection pop-up. I tried using the same FP controls in the event structures I have setup in each case, as only one event structure would ever be executing at any given time, but the program doesn't seem to like it ast run-time. I've worked around the issue by creating "duplicate" controls and using the property setting to make them visible/disabled, etc., but the is seriously congesting my BD.
    Anyone know a way to share controls with seperate event structures?

    It sounds like the root problem is the overall structure of your program. I highly recommend that you check out the Queued Message Handler project template in LabVIEW 2012, that will show you how to utilize a single event structure and pass events to a consumer loop. If you program is too large to consider an architecture change at this stage of the game, then there is a workaround for your problem.
    What is most likely happening is that you have the event structures all set to lock the front panel until the event completes. However the case structure that you have wrapped around these event structures is causing all but one of these event structures to be unreachable thus preventing you from handling the event. Again, as I stated above, the "RIGHT WAY" to fix this is to select a better program structure but the "kluge work-around" fix is this: Dynamically register for the value change event on all of the controls you are trying to trap events for. Dynamic events can be deregistered and re-registered at run time. This will allow only the event structure in the active owning case structure to be registered for the events, thus no other event structures will get in your way.
    Disclaimer: This advice is given based on very minimal information and a great deal of speculation and may not be correct. Please include your code if you need further assistance.
    Charles Chickering
    Architecture is art with rules.
    ...and the rules are more like guidelines

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

  • Stop execution of a loop in an event structure

    I tried searching the forums to avoid posting a duplicate, but most I could not open most of the vi's as they were higher version.
    I put in a dummy while loop in an event structire i intend to use. Once I start executing the while loop, I am not able to stop it using a control for some reason from the fornt panel control.
    I am not able to change the vale of the Stop control at all. I tried creating a seperate event for STOP, and I still could not stop the program when the While loop was executing.
    I imagine I am missing something really small. I would appreciate your feedback on this.
    Thanks,
    Nevil
    Solved!
    Go to Solution.
    Attachments:
    FrontPanel.vi ‏34 KB

    Right click on the event structure and choose "Edit Events" for the case that is giving you trouble.
    Be sure the checkbox to lock the front panel is unchecked.
    I suspect yours is checked, so your front panel is locked out until the event completes, thus you can never stop your loop.

  • Event structure in Sub VI

    Hello ,
     I have a developed a program which captures video and user can save images out of it. I have used .NET reference to handle the video part, and the VI is attached in this post. Now i have to make this VI as a sub VI and running this from Main VI. I tried creating event structure in Main VI which i used in sub VI , still i could not suceed. Kindly assist me in this regard
    Solved!
    Go to Solution.
    Attachments:
    Webcam-Control-Projekt-mit-Reference-Design-2013_original.zip ‏286 KB

    Hello Michael,
     I have attached a model in which Main VI calls the Sub VI using Event Structure. Two events can occur in Main VI and their corresponding event Structure is called in Sub VI using Register events. When i run this VI the out put is fine some times but other times i need to trigger event many times before i can see its effect in Sub VI, my doubt is that Register events are reliable, whenever (during the execution of LV) if event occurs will surely its code in the sub Vi gets executed?
    also I have put a indictor(numeric) in the SUb VI which i connect back to Main VI, when i run, i can see the result only in the sub VI not in the main VI.how to see in Main VI?
    I have used the this model (which is attached ) to implement my project(which i already mentioned) . one switch for starting the video and other for recording the image. The video is getting started with out any trouble, but imgae is recorded only few times when i press the button which is for image recording, most of the time second event fails to get executed. Also there are difference in output when i run with and without "Highlight execution", why this happens, is this because of Reg events?
     any more info if required let me know, i will provide.
    Attachments:
    Main_sub_VI.zip ‏18 KB

  • How to make Vi file as input file in Event structure?

    Hiii All..
    i got problems when to construct a event structure. The file input  (vi format) doesnt have source of wire connection to conect the wire (shift register) .For your information the vi that i create only contain simple mathematical equation.
    I already study the New Event Handler Example. but the file input for that example (acquire data.vi) have a source of connection. anyone can help me? 
    thank you very much
    [email protected]
    Solved!
    Go to Solution.
    Attachments:
    TOTAL.vi ‏18 KB

    Well, in your subVI you do need to wire up some inputs and outputs to your connector panel.  As I said, a basic LabVIEW skill that you will find in the tutorials.
    You have a number of inputs to your subVI.  More than you would want to attach to a connector panel.  You should perhaps use a cluster to group them together.
    To get you started, here are the steps to connect a control or indicator to the connector panel.
    1.  Open subVI.
    2. Right click on icon at upper right.  Show Connector.
    3.  Hover over a block you want to be a connector terminal, it will change to a spool of wire.  Click.
    4.  Go to the control or indicator on the front panel that you want to associate it with.  Click again.
    5.  Repeat as needed for other controls and indicators and save your subVI.  Now the subVI instance in your main VI can have wires connected to it.
    You should plan your connector panel so that controls are on the left side of the panel, and indicators on the right.  This will allow data to "flow into" and "flow out of" the subVI in a normal looking left to right orientation.

  • 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 use a event structure with a state machine

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

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

  • How to use an Event Structure responding to an image control that belongs to a parent VI.

    Hi
    I am loading a subpanel vi by pressing a button located in the user interface of the main vi which also contains an image display. Subpanel vi opens up on the side and doesn't hide the image display of the main vi. Subpanel vi contains an event structure that needs to respond to user clicking on the image display of main vi.
    Since the bug that occured while creating an image reference control isn't fixed, I am passing the main vi pane reference onto the subpanel vi. From that point I've tried to edit event structure and have it respond to the image control/pane that belongs to main vi but I don't know how.
    Any help would be appreciated.
    Thanks

    Post a screenshot of your subVI code where you register the events.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • Event structures used to monitor indicator change

    I am new to the event structure.
    Is it possible to monitor an indicator for a value change?  I know this works with controls, but I'm not sure you can monitor and indicator in this way.
    Thanks,
    -Nathan

    Yes, it's possible. However, in order to change the value so that an event will fire, you'll have to use the value(signalling) property of the indicator. It won't work if you simply wire a value to it.

  • Using Event Structures with Array of Clusters

    Using LabVIEW 8.5
    Hi all,
    I'm trying to convert an existing application to one that can be used
    through a touch screen. I updated the UI and added an event structure
    to listen for mouse ups on controls that require a HMI keyboard or
    numpad to show up. Although I've been programming for a while, I'm new
    to LabVIEW and am struggling with a problem:
    Is there any way to have an event case listen to an event within
    arrays? I've seen a few examples on the forums, but they all start with
    breaking up the arrays into individual variables. Using the variables,
    they build arrays. This seems pretty tedious, and I'm pretty sure I
    can't apply it to one of my arrays. Essentially, I just want to know
    which cluster in which array the user has clicked on, so I can open the
    HMI keyboard or numpad and send the text to that cluster. In my watered down app (Array of Clusters.vi), I've put 3 arrays of clusters and a few stand-alone controls to give you guys an idea of what I'm taking about.
    BTW, I'm using the HMI Keyboard and Numpad built by the Beta Community (http://decibel.ni.com/content/docs/DOC-1062) and modified it to add a "Clear" button to the keyboard and numpad. Please let me know if I implemented this in the best way.
    Thanks for the help,
    Kunal
    Message Edited by bhatiak on 08-04-2008 03:55 PM
    Attachments:
    Array of Clusters4.llb ‏274 KB

    My old tic tac toe example shows how to determine which square of a 2D array has been clicked.
    http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=247044#M247044
    You probably can adapt some of it for the arrays on the right. If the array can be scrolled, you also need to account for the "indexvals" offset.
    The Layers controls is easiest, because you only show one element. Just read the "index vals" property to get the array element and parse the coordinates to get the cluster element.
    btw: the small while loop on the right serves no purpose at all and acts just as a CPU burner. You can delete it without any change in functionality. Is there anything else to it?
    LabVIEW Champion . Do more with less code and in less time .

  • 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

  • Can I get the event structure to NOT queue events?

    I was wondering if it is possible to have the event structure not queue events that happen while the vi is executing code associated with another event. Basically, I have a toggle switch that, when "on", captures a live feed from a camera and displays it to the screen. This is done in a while loop that executes until the toggle switch is turned off. At this point, that event is done and the vi returns to the uppermost level of the event structure and resumes looking for events. The trouble is that the whole while the video capture was happening, the event structure was queueing events that were occuring during that time when the user was hitting other front panel buttons that had their own event associated with th
    em and would not execute at that time. When the video capture toggle is turned off the event structure then executes any other events that were queued during that time and I don't want it to. I can't lock the front panel while the video capture is happening so the user can't push buttons because they have to be able to push the button to turn the video capture off. Any suggestions? Thanks in advance.

    > I was wondering if it is possible to have the event structure not
    > queue events that happen while the vi is executing code associated
    > with another event. Basically, I have a toggle switch that, when
    > "on", captures a live feed from a camera and displays it to the
    > screen.
    I think there are lots of other articles about this on devzone.
    To summarize them, the key is that the event structure intentionally
    synchronizes events with diagram execution. The typical way to do what
    you want is to have the event start up another loop or subVI running
    asynchronously.
    Usually there ends up being one loop with an event structure in it.
    Another loop that executes a statemachine, possibly as simple as just
    two states of acquiring and not. Use the events to pr
    od the other loop
    between states via locals, globals, occurrences, etc.
    Greg McKaskle

Maybe you are looking for