Event structure - "first run"

Dears all,
how can I manage the "first time" of an event structure?
See the VIs enclosed.
Thanks a lot at all.
Attachments:
Event structure - first time.llb ‏44 KB

You don't need to mess with dynamic events. Simply add a timeout event to the event case you want to trigger.
Feed the timeout terminal from a shift register initialized with zero and wired a -1 to the shift register on the right.
The event case will immediately trigger once due to timeout. After that, the timeout will be infinite.
(See attached image)
Also have a look at my old post. The need for a generic "initialize event" has been discussed long ago in more detail, but I can no longer find the thread.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
FirstRun.gif ‏11 KB

Similar Messages

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

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

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

  • Event structure - general

    hello
    this is probably something that had been treated millions times, however i could not find direct answers from previous threads on that, so i ask directly.
    i am a bit confused by the utilisation of event structures:
    first, one would expect that if the event is used, say in a while loop, then outgoing data would be kept trough the sequence, without having to wire trough the other events, unlike as depicted in the pic below. that should be to my understanding the definition of "use default values" on the outgoing data nodes.
    however it seems not to work like that. why? is there a way to force LV to do as i want (instead of "use default values", make him "use last input value")?
    wiring trough all the nodes make the event structures very unelegant.
    second: this is probably a very naive one, but i dont like the way i do it: in some events i have same operations going on as on turn on of the vi. in other words, when i initialise my system, i pass trough several operations, which also exist in the event structure. to make the diagram more elegant it would be usefull to call all those events programmatically a first time. up to now i do it by programatically signalling the values of some controls. however there must be a more elegant way, where i could just queue the events needed. any suggestions?
    Message Edited by Gabi1 on 05-17-2007 06:11 PM
    Message Edited by Gabi1 on 05-17-2007 06:13 PM
    ... And here's where I keep assorted lengths of wires...
    Attachments:
    event structure.PNG ‏10 KB

    Jarrod S. wrote: 
    Triggering events forces a thread swap to the
    user interface thread, which can slow down execution. It can also make
    a redundant copy of the data that has to get stored in the control
    whose value change was triggered, which you might not need. Enqueuing
    commands onto a queue does not have these limitations.
     To clarify Jarrod's comment, it's important to note that neither the event structure itself nor dynamic events cause a switch to the User Interface Thread.  Functions inside the event structure (e.g. property nodes, invoke nodes) can cause a switch to the UI Thread when they operate on UI components.
    In that discussion, Jason King points out that:
    "There is nothing specific about the event
    structure that requires the event-handling case to run in the UI
    thread.  In fact, there is not any event that will force it to run in
    the UI thread"
    "Reading from or writing to a front panel terminal or local variable does not cause the diagram to run in the UI thread."
    "Any actual processing of user interaction,
    however - either looking at user interaction to determine which events
    to generate or finishing processing a filter event after the event
    structure has had a chance to discard it or modify any of the event
    details - requires the UI thread."
    "Pretty much anything you do with the reference to
    a control or indicator will cause a switch to the UI thread (property
    nodes, invoke nodes, etc)"
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs

  • How to control the tab control using event structure?

    Hi,
    I am using tab control and event structure in the program.
    When i run the application event is not happening for the active page.
    When user switches from active page to the other page then event is taking place for all pages
    So, how to get the event trigger for the active page when the application is started
    For more clarification i am attaching the code "Test Control Tab using Event Structure.vi"
    Attachments:
    Test Control Tab using Event Structure.vi ‏52 KB

    You have a basic misunderstanding of dataflow. Maybe you should start with some tutorials or study some of the examples that ship with LabVIEW.
    The event structure belongs inside the while loop, and not vice versa. RIght now, the event structure only runs exactly once and never again.
    If the stop is pressed first, the VI will stop. Game over.
    If the tab control is changed (from any state to any other state!), the inner loop will spin forever as fast as the CPU allows, either executing one or the other case. It just reads the tab terminal to decide which case to execute. Changing tab never triggers any events. The VI is trapped inside the event until stop is pressed to stop the VI.
    you were closer to a reasonable program in the other thread:
    http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=287905
    Have you tried execution highlighting? Maybe things would become more clear of you do.
    LabVIEW Champion . Do more with less code and in less time .

  • Need to paste on/off button in its own event structure?

    I am studying the CLD exam car wash vi attached.
    First question, I noticed the Start button is pasted inside its own event structure. Is this absolutely necessary, can I just paste somewhere else? 
    I guess it was paste there because the Start button has no wiring so it looks neater to paste in its own event structure, am I right?
    Second question, I noticed the Stop button is already wired to the red while loop stop, so pressing it would stop the vi already. But there is also the Stop value change event, this looks redundant, no? Or is it something really necessary??
    Solved!
    Go to Solution.
    Attachments:
    Car Wash LV86.zip ‏73 KB

    Both are necessary.
    1. The boolean's terminal while be read when the event is triggered. This read triggers the latch operation (so the button snaps back).
    2. The event structure would wait for an event and nothing would happen until another event is triggered. Only after the event structure is 'run', the stop value is read.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Radio Buttons and Event Structures

    Guys, I am hoping for some help here on something I probably should know but cant figure out how to do.  I am using a set of radio buttons and an event structure to run a UI.  The radio buttons are acting as both a user input and indicator of current status selected by the user.  I have the event structure set to run on value change of the radio button.  All works great unless the operator decides that he wants to repeat the selection that the radio button is already set to.  The event structure does not recognize this as a change of value and will not execute.  Is there a way to set the event structure up to run even if the same selection of the radio button is made a second time?  I attached a crude example to this post.  Basically everytime I press the button, I want an entry made into the text box, regardless if the selected item was already pressed.  Any thoughts.
    Troy
    Attachments:
    Radio Button Test.vi ‏16 KB

    Instead of hacking around the inherent nature of radio buttons, why not just use a Cluster?  Its behavior in the UI is more customizable.  Check this out:
    I just replaced your radio buttons with a cluster, and added a little logic to the event structure to get it to behave the way you describe.  I've attached the VI below, saved in 8.2, if you want to try it out.
    Hope this helps,
    -D
    Message Edited by Darren on 11-07-2006 10:45 AM
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    cluster_buttons.png ‏7 KB
    Cluster Test.vi ‏17 KB

  • Event structure in a subVI

    I know this problem has been posted, but I've already am passing everything by reference. I can't get my subVI to respond to my top layer VI. It runs fine as a stand alone, but when I ask it to monitor events from a reference, it won't do anything. I've attached what my sub VI looks like. My goal is to have the the event structure respond when a new file path is sent, stop button pressed, or a enum is changed. The subVI is called Read Track shown in the top VI with all the references passed.
    Top VI
    Message Edited by d1sturbanc3 on 02-27-2008 12:30 PM
    Message Edited by d1sturbanc3 on 02-27-2008 12:31 PM
    Attachments:
    event.JPG ‏163 KB
    top event.JPG ‏301 KB

    You should use dynamic events.
    Your SubVI with the event structure should run in parallel with your main code.
    What you currently have will never work.
    Here's an idea of how the subVI should look like:
    Try to use the Code Capture Tool to get images of your code...
    Good luck,
    Ton
    Message Edited by TonP on 02-27-2008 07:45 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    PathEventChange.png ‏5 KB

  • Loop with event structure

    I put an "event structure" inside of a while loop. My target is to keep the
    VI running and make selections to run different subVI. But I got two
    questions:
    1. how to use two button on front panel? I mean, when I press one button,
    step 1 runs, when I press the other button, step 2 runs. Is event structure
    the best way to do that? another side quesition is that how I can make the
    button jump back after I pressed it? It kept in the "down" position and I
    have to press it again to release it.
    2. When I test the VI, I found the while loop can't stop. The boolean input
    of false won't stop the VI. I wonder if there is a rule that the event
    structure must run at least once? or any other hidden properties I didn't
    notice?
    thank you very much!
    cheng

    "Michael Sachs" wrote in message news:...
    > You can change the boolean's mechanical action to a latched type and then it
    > will pop back up.
    > The event structure has a timeout input that defaults to infinite. If the
    > event loop is waiting for an event or timeout then your outer while loop
    > will not cycle. Use the hightlight execution lightbulb on the diagram to
    > see what the data flow is doing.
    >
    > Mike Sachs
    > Intelligent Systems
    >
    > "Cheng" wrote in message
    > news:[email protected]...
    > > I put an "event structure" inside of a while loop. My target is to keep
    > the
    > > VI running and make selections to run different subVI. But I got two
    > > questions:
    > >
    > > 1. how to use two button on front panel? I mean, when I press one button,
    > > step 1 runs, when I press the other button, step 2 runs. Is event
    > structure
    > > the best way to do that? another side quesition is that how I can make the
    > > button jump back after I pressed it? It kept in the "down" position and I
    > > have to press it again to release it.
    > >
    > > 2. When I test the VI, I found the while loop can't stop. The boolean
    > input
    > > of false won't stop the VI. I wonder if there is a rule that the event
    > > structure must run at least once? or any other hidden properties I didn't
    > > notice?
    > >
    > > thank you very much!
    > >
    > > cheng
    > >
    > >
    Hi Cheng,
    that's not quite the whole story. The event structure breaks down
    into two types. Those that get actioned between the start of the event
    (i.e. mouse down) and the result of that event (i.e. the button
    registers true) which are filtered events, and the other type (like
    mouse up) which occur after the event and the result of the event.
    With filtered events you can modify the result of the event as it
    happens. Whichever you choose to use, you need to do one of two things
    to get the button to pop back up (setting to latch when pressed on
    it's own won't work) - you can either read the FPTerm within the event
    itself with this set to Latch when pressed, or (my prefered method) is
    to use the CtrlRef that's available inside the event, and use the
    ActiveX method Reset to Default. This way the FPTerm for the button
    can be left somewhere else, and it's more obvious what the program is
    doing at this point.
    Your while loop is actually a do {} while loop, i.e. it must execute
    at least once before it checks to see if it should iterate again.
    Mike's suggestion of follow the hi-light execution is the best
    solution.
    Hope that helps
    Sash.

  • Successive run - Event Structure

    Hello...
    I have a simple question. Sometimes we want to use Event Structure and put only a piece of the code in each case. The problem is that a case might have only math code, without any control, indicator or array. Because of this, this case will not have any "thing" that can trigger its execution. 
    To avoid this and allow me to control in arbitrary form the execution of the cases, I created a simple code where I can specify which case will be runned after a especific case.
    Attached there is a example just to show how it works.
    My question, is there a better way to do this?. I mean, specify that after one specific case runs, another specific case will run.
    Thanks in advance.
    Dan07
    Attachments:
    Event Structure Run.vi ‏30 KB

    There are various problems with trying to use the event structure itself to be the case selector for a state machine:
    You can't guarantee that cases will execute in a particular order, because other registered events could fire during a sequence and interrupt the intended chain of events. For instance, if a user presses a button while the event structure is in a sequence where it triggers itself repeatedly.
    It takes a lot of effort to create these hidden controls that only exist to fire value change events. And it makes the code confusing because they serve no real purpose. Yes, User Events are the preferred solution to this problem, even if they require more wiring and control, but they don't solve the first problem in the list.
    A better solution might be something along the lines of a Queued State Machine architecture. It's a mix inside one loop of an event structure and an outer case structure. It's a little difficult to explain in words, but there's a good template free to download from JKISoftware that also has a tutorial video about it that you can learn more about here. I've recommended this before, but I promise I don't work for them or anything It's just good technology and a lot of thought has gone into it. JKI didn't invent the paradigm, but they've implemented it pretty it well.
    It seems to solve a lot of the problems you have. It allows for user interaction through the event structure, and it allows you to trigger a sequence of cases not related to controls or indicators that have events registered for them. And it solves the two problems listed above. The architecture is inherintly self-documenting and clear, and it avoids the pitfall of allowing user interaction to unintendedly interrupt import sequences of events.  The downside is that it's not the simplest of architectures, but it's also not the most complex. Check it out!
    Jarrod S.
    National Instruments

  • Run event structure on startup

    i have an event structure in a while loop.
    when I run the vi i wish to run one of the events 1 time without a user input.
    can this be done?? and if so how??

    This does not work with latch action booleans, you need to fake latch action with a switch action and a local variable. The attached modification show a working version of your VI.
    Of course I typically prefer a solution similar to George's.
    The need for a generic "first run" event has been discussed before, see my example and discussion in this old thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=108599#M108599
    Message Edited by altenbach on 03-17-2006 08:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    InitEventMOD.vi ‏14 KB

  • Event Structure Freezes Vi After Capturing The First Event

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

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

  • First event fired to event structure

    Hi all,
       Does anyone know what's the first event being fired to the event structure on VI startup? I set a breakpoint on the event structure and it breaks. However i wasn't able to capture whats the event.
    My intention was simple; i have a table which list all the IO names and values. So during VI startup, i wan to populate the IO names first. Then in a timed-loop, the values are updated respectively. In this case, i don't need to "refresh" the table every time which waste time and resources.
    It something like the OnLoad event.
    Another way out is to register an user event, and have this event fired during application startup. But i wonder if anyone has a better way?
    Many thanks!

    j3r3mi wrote:
    My intention was simple; i have a table which list all the IO names and values. So during VI startup, i wan to populate the IO names first. Then in a timed-loop, the values are updated respectively. In this case, i don't need to "refresh" the table every time which waste time and resources.
    Why don't you show us some code.
    Are the IO name static for the duration of the program? Are you using a regular table column or the "row header strings []" property for the IO names?
    If you want to write the row headers at the start of the program, place the code before the main loop containing the event structure. No event case needed. If you have a specific event to update the table headers if needed, fire the event once at startup using a signaling value property, again with the property node placed before the main loop.
    LabVIEW Champion . Do more with less code and in less time .

  • How to run a vi by referencing in event structure

    Hi
    I searched for an example in Event structure. I just modified that but i am getting error(error code :1 )message when i run the program.
    could anyone give suggestions why is it so.
    I have attached the example program and my modified program
    Thanks
    Attachments:
    Untitled 10.vi ‏18 KB
    Main Launcher.llb ‏65 KB
    A.vi ‏9 KB

    [Edit: Sorry just a minute late. Even not able to remove the attachments. Its throwing some exception error.]
    Sorry, your request failed. A notification has been sent to the development team to investigate.
    Exception ID: 3A98D61C
    Please click the Back button on your browser.
    Message Edited by mathan on 06-27-2008 06:34 AM
    Message Edited by mathan on 06-27-2008 06:38 AM
    Attachments:
    Untitled 10.zip ‏19 KB
    Main Launcher1.llb ‏30 KB

  • Run-Time Menu and Event Structure~~HELP~~

    Hi, brothers,
    I'm new user for LabVIEW. Use the version of LabVIEW is 8.6
    One problem describe as below:
    Can Run-Time Menu and Event Structure exist simultaneously?
    Without Event Structure, Run-Time Menu works well, but Run-Time Menu works abnormally.after adding Event Structure,
    How do I modify the problem?
    Thank you for your help.
    Attached is the program.
    Attachments:
    PC_Adjustment.zip ‏44 KB

    Yes they can coexist, but not how you did it.
    Every iteration of the while loop you wait for an event in the event structure, and you look if the user has selected anything from the menu.
    To get this working you should add an event for <this VI>\Menu Selection (User):
    Ton
    PS you should add a stop button, the only way you can stop the VI is hitting the 'emergency stop' button, with hardware connected (like you have) this is not the adviced routine
    Message Edited by TonP on 09-26-2008 07:34 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Main_BD.png ‏5 KB

  • Why does my event structure run a single click when I double-click?

    I would like to treat single-clicks differently than double-clicks but it appears that when I double-click an item on a Front Panel control it runs the single-click event once before running the double-click event.  I would like the single-click event not to trigger if the user double-clicks.
    I am discarding the "Mouse Down?" filter event then using the "Mouse Up" notify event to try to catch the difference between a single-click and double-click.
    Should I be doing something different with the timeout event (right now it does nothing)?
    Should I stop displaying the event type?
    Should I eliminate the 5 msec Wait in the Producer Loop?
    Should I use the "Mouse Down" notify event instead of the "Mouse Up" notify event?

    JeffOverton wrote:
    If you edit the event cases, is the "Lock front panel until the case for this event completes" box checked?
    I think this is a key configuration to understand.
    The current configuration means that the 'mouse up' event for the first click is triggered. Then immideatly the front panel is locked. The second click needs to wait until the event has finished. So I think unchecking that box might improve the code.
    Yes you should remove the 5 ms. wait, it has little purpose. It might even cause this: Click 1(& lock), wait 5 ms, event 1 (&unlock), click2 (no double click anymore).
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

Maybe you are looking for

  • How to delete music from Ipod Touch?

    there r some songs that r only in my iTouch that iTunes does not detect. I even tried to delete it manually but in vain. As I cannot delete them in my iTouch is there any way I can remove them.

  • How to clean up of empty blocks in a Essbase database.

    Is there a way or a script that I can write to get a list of all empty block in a calced block storage application? For example I would like to find out which generation 3 blocks are empty (after aggregating) in a given dimension, extract this list o

  • How do I move all my Firefox settings to a new computer.

    My old pc is not working but I have the hard drive and access to all my files. all I am trying to do is move all my settings for Firefox...bookmarks, passwords and settings, to my new machine. I cannot do the sync, I cannot do a backup and restore as

  • Converting Word (97-2003) docs with tables

    I have tried converting a few Word docs with tables using Acrobat.com. There is one small image in the upper right corner that in the converted doc stays in the same place so I know that is not the issue. What happens is that the converted document t

  • Arabic language for N73 music

    I need N73 music edition arabic language software update