Handling event structure in subvi

I go through fierce problem for using event structure in subvi. 
Main VI contains event structure in a SubVI
Event structure is composed of two event. one is "Time Out" , the other is "Value Change".
What I want for this VI is Time out event works without a delay time , except of case of Value Change event 
But "Value Change" event of this VI is not working properly. Even when  Value Change event is working , "Time Out" event is still working.
To explain in more detail,  When Value of Boolean is changed , ligh of Boolean Out must turn on.
Please, help me.
Attachments:
example.zip ‏14 KB

Hi,
Have a look at the attached vi. your value change event is working properly but once after that event is fired it will be going to timeout there we are sending false to the boolean hence your not able to observe the value change occured.
Attachments:
main vi Folder.zip ‏9 KB

Similar Messages

  • How to handle event structures for two buttons and two counters.

         *I have two buttons A and B, and have to compare the difference in hits between them.  So do I place an event structure within a while loop for each button (2 buttons, 2 event structures, 2 while loops), or does it need to be one event structure with cases for both buttons whithin one while loop? 
         *How do I pass the values of buttons A and B's hit counters out of the while loop in order to calculate the differences between them after each increment, not just the final count after the stop button is hit? 
         *How would I make one stop button work to handle both buttons A and B?   I tried to place the actual stop button in one button A's structure and its global in B's structure, but It wont seem to let me use a local variable for a latchable control
    Checker

    You should probably have not started a new thread and waited until your question in the original thread was answered. You can modify altenbach's example for a second button. You have a single event structure with a new event for the second button. You have a second shift register to track the number of times the second button is pressed. Inside the while loop but outside the event structure, you just have a subtract function in or to report the difference. do not modify the posted example for the stop button. It works perfectly as is.

  • Trigger Event Structure in SubVI

    Here's my goal.  I have a VI that sets two analog outputs which in turn control a power supply.  One output controls voltage while the other controls Current Limit.  I created a VI which uses an event structure so that when the voltage or current limit is changed, the analog outputs are adjusted accordingly. 
    Now, I'd like to turn that into a SubVI and have it running in the background while my main VI runs.  I'd like to be able to go into the subVI and change those values at certain locations within the main VI.  I tried just using the subVI with register events, but it hangs because it is waiting for the subVI to finish before continuing.  I tried using the Run VI methond with "wait until done" set to false, but then I don't see how to trigger my events because I can't link my mainVI to the events that need to be triggered.  I can set the control using Control Value Set, but that doesn't do anything for my event structure and thus stuck again. 
    Maybe the event structure isn't the best way to do what I'm seeking.  But I don't want to set all this up in my Main VI because it just adds too much complications and I already have the VI working by itself and just want to turn it into a subVI.
    Thanks.

    You could either get a reference to the SubVI and find the specific control like the attached picture, or you could pull the SubVI out of the main loop.  If the SubVI is necessary for data flow, you are almost certainly going to have a hang up if you don't call it by reference.
    edit - Another, probably less popular, option would be to have the subvi running in a parallel loop and have locals take data from the control loop and write to the command loop.  You'd have to be careful to only have one local writer, though.
    Message Edited by JeffOverton on 01-30-2008 02:39 PM
    =============
    XP SP2, LV 8.2
    CLAD

  • Handling events in subvis - think this should work but it doesn't.

    In part of a large project I need to handle key down events, but elsewhere I need to handle them differently and want to be able to dynamically register and unregister them in each location. I also want to be able to put one of the event handlers in a subvi. To quote the Help system, "Dynamically Registering Events: With dynamic registration, you can handle events in a subVI rather than only in the VI where the events are generated."
    ViThatHandlesEvents.vi handles key down events. It uses dynamic event registration to demonstrate that it works (though in this simple example it isn't necessary).
    ViContainingSubviThatHandlesEvents registers key down events and passes this to KeyDnEventHndlrSubVI. I thought it would work but it doesn't.
    Attachments:
    KeyDnEventHndlrSubVI.vi ‏14 KB
    ViThatHandlesEvent.vi ‏22 KB
    ViContainingSubviThatHandlesEvent.vi ‏18 KB

    cebailey wrote:
    Here's a version with Panel > OwningVI > Key Down selected in the nodes that register events. It seems to do what I want. It acts on keystrokes that occur when the cursor isn't even over the parent's window, which is good in my situation. I made these choices by experimenting - is this a good approach, if I want to act on all the keystrokes that occur when the parent VI has focus?
    As you noted, this will have the event structure respond to keypresses whenever the parent VI is active. You can simplify the subVI by simply wiring the "VI Refnum" terminal directly to the Register for Events node. Getting the Panel, and then the Owning VI simply gets you back to where you started.
    That's a valid way of doing it, and I'm assuming that this is intended to be a test case. As you noted you have a large project, so I don't know what your overall architecture is, or how you intend to use this technique, so I can't really say whether it's a "good" approach. It's an approach.
    Say, I should have said this before, but you have to be pretty good to answer the question somebody should be asking, especially in brief forum postings.
    Thanks for the compliment. It's just a matter of seeing a lot of code and a lot of questions. I'm only a teenage pup compared to the real veterans on this board.

  • Handle runtime menu in subvi event

    I am passing the runtime menu reference to a subvi event structure for processing the top-level runtime menu in the event case. I already have a registered case to handle any change in the top level vi control values. Since, I'm passing a runtime menu reference to the subvi, I initially thought I can handle the runtime menu in the subvi event. When I add an event, runtime menu is not a choice when setting the event up. The event setup does show "shortcut menu" as a selection but this must be for a context menu or the like.
    Thx ahead of time,
    richjoh

    Hi Richjoh,
    what you should do is pass the VI-refnum into the sub-vi, and register there for menu events! A menu reference, does not cover a FP-object so LV has no events for it.
    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!

  • Can I use Event structures in a subVI?

    Hi,
    I have a subVI (ProvaEv1.vi) that use an event structure inside. But when I use it in a VI (ProvaVI.vi) the event structure in the subVI doesn't catch the events.
    I tried to insert the event structure in a while loop but it doesn't work too.
    Could you help me?
    Thanks Ius
    Attachments:
    ProvaVI.vi ‏11 KB
    ProvaEv1.vi ‏15 KB

    "iusn" <[email protected]> wrote in message news:[email protected]...
    Thanks to all for your answers!
    Wiebe! I tried to do as you suggested but I am not able to link the Event Reference Number inside te SubVI with the Event Register Number of the Register for Event in Main VI. There is e class conflict. Another question: how the SubVI can know the structure of the Register event outside?My aim was to create a modular structure but it seems very difficult, wath do you think about these problems?
    The broken wire is related to your question. The event structure inside the sub vi knows about the events you register in the main, because the reference wire/control has a "strong" type. It contains information about the registered events. That is also why the wire is broken. You have to register all events, then create an indicator/control of the output. Use that control in the subvi. You have to do this every time the events change (you might use a type def if you use the control a lot).
    Usually, the events that you would want to put inside subvi's are those related to user interface objects. I've had this a lot. You make a nice interface, but it's not reuseable, because the events are mixed with all the other events. Only solotion is to manually add the needed event cases in your program, and copy the code.
    Even if you can put the events in a sub vi, I'd expect hanging vi's when more subvi's are registered for the same event. It's hard to tell without trying. So it's not a real solution either.
    Like Chrisger suggested, the event callback might help a little, but they are tricky, and actually ment for this (they are intended for activex callbacks).
    Perhaps you should look at XControls (if you use 8.2). It would be more work to replace your code to XControls, but once you're done, you have reusable code.. Haven't worked with them jet, but they are invented for this problem...
    Regards,
    Wiebe.
    I have already create my application using event structure just in Main VI but it seems very complicate to read and keep update, I would have wanted to give modularity to my application.
    Thanks Ius
    SubVIEventMain.vi:
    http://forums.ni.com/attachments/ni/170/203225/1/SubVIEventMain.vi
    SubVIEvent.vi:
    http://forums.ni.com/attachments/ni/170/203225/2/SubVIEvent.vi

  • 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

  • SubVI with while loop + event structure not working in multi tab VI

    Hello Everyone,
    I am developing an interface for the control of a prober using Labview 2012, and I am stuck with some issue.
    To start with I provide you with a simplified version of my control interface VI, and with the sub-VI used to build and manage the wafer maps.
    The VI consists of several tabs: Prober Initialization, Wafer Handling, Wafer Map, Status, Error.
    The sub-VI can:
    1/ initialize the grid to display the map (sub VI Init Grid not provided here)
    2/ import XY coordinates from a txt file (sub VI Wafer Map Import)
    3/ display the coordinates and index of the die below the cursor
    4/ and when a die position is double clicked, and the boolean "Edit Wafer Map" is true, then the user can change the state (color) of the die between On-wafer die and Selected Die
    My issue:
    If I use the sub-VI by itself, it works fine. However when I use it as a sub-VI in the tab "Wafer Map", the map does not build up and I can no further use the embedded functionalities in the sub-VI.
    I suspect the while loop + event structure of the sub-VI to be the bottleneck here.
    However I don't know which way to go, that's why I'd be glad to have some advice and help here.
    Thank you.
    Florian
    Solved!
    Go to Solution.
    Attachments:
    Control Interface.zip ‏61 KB

    Hi NitzZ,
    Thank you for your reply.
    I tried to save the VIs in LV10, please tell me if you can open them now.
    Inside he event structure there is quite some code, and since I don't want to make the main vi too bulky, I would like to keep it as a sub-VI. 
    As you can see from the sub-VI, the event structure is used for extracting cursor position and tracking the double click action. These events are linked, through a property node, to the image "Wafer Map" which is passed to the main vi through connector pane.
    All values are passed this way as well (through connector pane). Is there another way?
    Maybe "refnum", but I don't really understand how to use them...
    If I use the event structure in the main vi, the wafer map is still not working. I tried it earlier.
    To implement the multi tab front panel, I used a tab control, and a for loop + case structure. For each element of the case structure, there is a corresponding action.
    For the case where I put the code (element=2) for Wafer Map, I also control the execution of the code with a case structure activated by the button "REFRESH". Otherwise I end up with a freezing of the panel right after the start.
    I hope these comments help you understand better.
    Regards,
    Florian
    Attachments:
    Control Interface.zip ‏104 KB

  • Handling event in subVI

    Hi all,
    I register an event (value change for a boolean array) in a subVI.  I connect the refnum with the dynamic event connector (event loop) the in the higher level VI.  So the loop will fire when the subVI's boolean array change.
    It works well only if the front panel's subVI is opened.  I don't want the subVI running with the front panel opened.  Someone can help me to figure out what should be done?
    Thanks.
    Solved!
    Go to Solution.

    This is the expected behavior. I would recommend that instead of using the value change event create your own user event. Then have your subVI trigger this event when it modifies the array. The event structure in the calling VI will receive your user event and take the appropriate action. Relying on a value change event is not the best way to do these types of things. Also, using a user event helps to decouple the UI from the processing tasks. This is a good preferred design because it is more flexible and easier to change one side or the other. As long as the event data is consist you are free to change either implementation.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How to use a event structure in a subVI

    I am trying to use an event structure inside a subVI.  The subVI has an array builder that builds arrays, and the event structure is used so that when the program is running, it allows you to change the elements of the array.  It works, but when I implement it inside a subVI, it does not work properly.  This is going into a subVI, because it will be a part of a much larger progrram, so it needs to be modular.

    If you're using an event structure, it's not a subVI.  if you're worried about modularity, you shouldn't be using the event structure.
    You seem to have a fundamental misunderstanding of modularity.  An event structure should be placed within a while loop.  If you have a while loop within a subVI, you've handed over control of your program to the subVI.  You're not modular at this point.  Your top level GUI has no control.  You'd have to create some asinine system of variables to pass data down to that loop to stop the loop and return to your main VI.  That's not a good design decision.
    Instead of looking for a way to do something broken, you should spend effort trying to understand what you actually want to accomplish.  You should also spend some time learning how event structures work.
    This application is small right now and it's already on the path to unreadable.  That's a terrible thing to do to yourself.  Break these habits now.  se variables only when absolutely necessary.  Use subVIs to accomplish individual tasks, not run the entire application.  With event structures, use a stop button value change event to not be held hostage by the timeout.  If your variable has "2" in it, you're doing something wrong.  There has to be something different between the setpoints, put that in the name.  If you want to make subVIs, create an icon.
    But first and foremost, invest time in understanding dataflow

  • Is there a way to add an event to the event queue handled by the event structure?

    I am using an event structure to control the flow of a program. In one case I want to change the state of a switch and then have the event structure catch this exception and handle it. It works if the user toggles the switch, but doesn't seem to when it is done programmatically. Any suggestions.

    Hello,
    LabView User's manual says:
    "Use Events for Direct User Interaction Only
    Events wait only for direct user interaction on the front panel. Events do not work if you use VI Server, global variables, local variables, and so on to change VI or front panel objects programmatically."
    However, you can have a look in Example Code, there's some applications generating events programmatically, maybe that helps you. (Search for event structure in support).
    Hope that helps,
    SBC

  • Event structure doesn't handle all events from external DLL source

    Hi!
    I use a DLL, wich handles an USB CAN transceiver device, and generates LabVIEW user events with extcode.h and PostLVUserEvent() function.
    In my vi I use an event case structure to handle theese external events. The problem is, that if the events come too frequently, then it cannot handle all events.
    The vi contains a couple of parallel while loops which process the incoming data from the external event.
    In another application I use the same architecture, and that works fine. This one is more complex.
    Do you think I have reached the limits of the program? Or what else can be the problem?
    I have tried to use a queue in the  event structure, it helped a little, but yet, not all the events are handled. My external DLL sends all event, so the problem is not there.
    Thanks in advance!

    Hi Wasz,
    Thanks for the post and I hope your well.
    It is not possible for the event structure to miss events - it simply queues them up. To keep the event structure 'in time' with the code you must ensure the code to execute in each event is minimal to allow the event structure to handle the next event. 
    Please see this two links:
    event structure buffering: leading to,
    How to avoid built-up for "cursor move" events? : where somone is trying to avoid handling all events.
    What sort of events are not being handled? Could it be an issue your events are not configured correctly? Maybe if you could produce a small example in LabVIEW code, so we can just test the event structure configuration... someone working around the external dll call - which you seem sure is working correctly.  
    In terms of queuing to process the events in other loops is certainly an option to speed up the event structure. To do this, use a produce/consumer design pattern.
    hope this helps,
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

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

  • How to handle event from subVI in the main VI?

    Hello,
    I'm doing some measurement. During the measurement I want the user to see some activity dialog - that's easy to do. Before the measurement starts I dynamically run VI (EX_Progress.vi) that shows some activity and then I do the measurement (in my example simulated by random number generation) . After the measurement is done (or error occurs) I can dynamically abort the activity indicator. But on the other hand I want to give to the user chance to abort the measurement manually via the activity dialog by STOP button. There are some ways how to do it via global variable and check every iteration in the main VI it's state but isn't there some better way? Would be nice to run event in the main VI when the user pushes the STOP button in the Progress VI. Is it possible to achieve this using register events? I tried but don't really now how I'm not familiar with this technique.
    Thanks in advance
    Message Edited by ceties on 11-26-2007 01:34 PM
    LV 2011, Win7
    Attachments:
    Ex.zip ‏374 KB

    OK, here's an example using User Events. It doesn't directly have the main VI listen for the Button press event in the subVI. Instead, it has the main VI listen for a custom User Event that the subVI fires every time there's a button press. You could theoretically directly listen to the button press directly from the Main VI, but you would have to somehow get that control's reference to the main VI. That would require storing a copy of it in a global or some such method. This method I will show here is very common and is definitely worth learning.
    For more info on User Events, refer to the LabVIEW help. You can learn more by clicking any of the User Event VIs and selecting Help from the shortcut menu.
    (I didn't set the subVIs front panel to open automatically, so you'll have to do that yourself to see anything from this demo...)
    Message Edited by Jarrod S. on 11-26-2007 02:51 PM
    Jarrod S.
    National Instruments
    Attachments:
    Example.zip ‏25 KB

  • Handling DAQmx Sampling Rate within Event Structure

    Hello all,
    I've been programming in Labview for a while now, but have recently been introduced to Event Structures. They are useful, however I think in the program below, the event structure is causing me trouble.
    VI (Written in Labview 8.0): http://myweb.dal.ca/~jwoodacr/Pendulum.vi
    The program itself is fairly straightforward, and by no means complete. One event allows the user to acquire data in real-time (Preview Data Event), and uses the Wait VI to control speed (I know this is not particularly accurate, but the preview does not have to be). The other event is meant to collect data with a well defined time interval between data points.
    The problem is, I can press the "Collect" button once, and the "Collect" event will run fine with the values of "Time to Collect" and "Data points / sec" that were input by the user prior to pressing Collect. But, if one wishes to press collect again, no matter how you change the "Time to Collect" and "Data point / sec" controls, the express VI "DAQ Assistant 2" will only remember the very first values you gave it, and will output data with these parameters. So, if you change "Time to collect" to from one (1) to two (2) seconds after having run it initially with one (1) second, it will continue to remember the one (1), and collect data for only one second.
    I've attempted to replace the express VI with all the proper DAQmx VI's used to collect in an identical fashion, but those also do not update past the initial conditions that are set. If you enable "Highlight Execution" and watch as the task proceeds, the numbers that are sent to the "DAQ Assistant2" VI are all as they should be, based on everything input on the front panel. It simply seems to ignore them upon execution.
    This seems an odd problem, but I am hoping someone may be able to shed some light on it, or has experienced something similar in the past.
    Thanks in advance.
    Cheers,
    Jeff

    The DAQ Assistant only initializes the first time it is called.  Thus each subsequent call, it does not care about the inputs into it.  Another option is use DAQmx VIs and use a property node to modify whichever propreties you want.  You must stop the task before changing its properties.
    Brian R.
    District Sales Manager
    Washington DC
    National Instruments

Maybe you are looking for

  • XML Publisher report errors out when RDF report has no data

    Hi everyone, I created a template and attached it to an RDF. When i run the oracle report with the attached template, if the report has 'not data exists' the report is erroring out. is it the normal functionality of XML publiher??. Because i remember

  • Customer replication from R/3 to CRM as BP's in install at role

    Hi experts, Customer's already exist in our ECC system. In CRM, we need to create the ECC customer;s as BP in install at role. From some ot the previous threads, I found that PIDE transaction can be used. Can anyone explain me the steps clearly for c

  • Split Valuation For Material Having No Open PO & Stock

    Hi Experts, Will somebody throw light on split valuation where there is no any open PR, PO & Stock for that material but system does not allow to make material split valuated. System shows error meassge giving old PO nos list. (Logically all these PO

  • Mbpr won't boot up, stuck on white screen with apple logo when I turn it on

    This morning I noticed the apple logo on the outer shell of my mac was lit up, I thought this was very odd because the lid was closed and like all laptops when thier lids are shut the display ect. are supposed to switch off/go to standby? Anyway I qu

  • Extractor for Vendor Classification as hierarchy

    Hello, The standard don't extract more than one value for the classifcation. Then, I want to extract this data as a hiearchy. Example R/3: Vendor   Classification V1 G1 V1 G2 V2 G3 V3 G1 V3 G3 Then, the datasource should create this hierarchy: G1 ...