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

Similar Messages

  • 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

  • How to run the two events at the same time by using event structure

    In my project, I have to run two stepper motor which can run both forward and reverse direction by changing the control in front panel so I am using event structure. In front panel I gave two separate controls for both stepper motor such as forward,reverse and stop. I would like to do motor1 will rotate alone, motor2 will rotate alone and both motor will rotate at the same time when user click the control in front panel. My doubt is how to run a motor2 while motor1 is running at the same time please tell me the suggestion for this problem
    Attachments:
    motor.png ‏192 KB

    How do you control your motors?
    Most motion control systems do supply two modes:
    a) position based motion: The motion axis has a positioning system (most often some kind of encoder system) which enables the motion control to know where the axis is currently located. Passing the target location to the controller will result in the axis to move to that location. This is, for most applications, the recommended approach. It does require some sort of motion controller device.
    b) direction based motion: This essentially tells the periphery device for the motor to move at a certain speed into a certain direction. As it does not stop at a dedicated location, it induces great risks for many applications if there are no kill- and/or end-switches. Depending on the setup, this can be either done with motion controllers or pure by software control (e.g. "controlling" the voltage level for the motor).
    If you go for a), there is not much preventing parallelism as you request.
    Option b) depends on the setup. If you have a control loop in the software itself, you have to move to an architecture like the producer/consumer. Please note that this does not incorporate any security measures for the external devices.
    hope this helps,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Problems using event structure to write new parameter values to VISA

    Attachments:
    FMA_event_2.vi ‏28 KB
    FMA_event_2.vi ‏28 KB

    It seems I'm also having trouble using forums..not sure what happened...updated and corrected thread: http://forums.ni.com/t5/LabVIEW/Problems-using-event-structure-to-write-new-parameter-values-to/td-p...

  • How to use event structure of event data nodes event filter nodes in programming

    hi,
    I need manual of how to use 'event structure' events of 'event data nodes' and 'event data filters'...please help me....
    Regards
    Ravindranath

    I'm not really sure what you are looking for here.  Did you do a search in the LabVIEW help for Event Structure?
    The Event Data Node just returns information about the event, like control data, control reference, what caused the event, etc.
    The Event Data Filters are just used in Filter Events.  This allows you to discard an event or change the data that the event will recieve.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Exit from the application using event structures

    Hi
    In my project i used event structure it working fine.
    Now i want to exit(close) the application when i press EXIT button on the front panel.
    Here i attached my project give an idea.
    Regards
    hari
    Solved!
    Go to Solution.
    Attachments:
    Sledge.zip ‏40 KB

    Hi SAM
    U saw my ok.i have one more problem when i run the program(main vi) all the remain sub vi's also opened.
    i want open sub vi when i press a button on front panel.
    i have made small changes to it.
    Regards
    hari 
    Attachments:
    Sledge.zip ‏41 KB

  • Stop graph using event structure

    How could I stop the wavform chart during running the loop using event structure?

    duplicate post
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

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

  • 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

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

  • Locked panel using event structure

    Hi!
    I'm using an event structure block to run a sequence only when a value of a control has changed.....when I edit this event I set the option NOT to lock the front panel.
    When I run the vi's I can change the controls of the front panel......but all the code outside of the event structure block does'nt run....what i have to do?
    I've attached a simple example.....boolean2 can change his value but the code is not executed
    Thanks in advance
    Larson
    Attachments:
    example_event_error.vi ‏42 KB

    hi there
    the while-loop waits for all the code contained in it to finish until it turns again. the event-structure has no time-out case defined, so if "Boolean" dosn't change it waits eternally. that's why the "Boolean 2" seems to be locked, because this code is not executed any more until the next turn of the while loop.
    add a timeout-event (event source = Application) and connect the event timeout (e.g. 100 ms). be aware that the reaction to a change of "Boolean 2" takes up to timeout ms. another option is to put the code inside the timeout-case.
    best regards
    chris
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • Firing events from a Menu using Event Structure - all in the same Event Window?

    I have an ap where I have three menus, and several selections from
    those three menus. I'm trying to keep everything within the Event
    Structure, but it seems that ALL of the events fired from the Menu must
    be contained within one "frame" of the Event Structure, that being the
    Menu Selection (user) Event. In other words, if I have 16 events that
    can be fired from the menu, do I have to put them ALL in this one event
    frame?
    I can't seem to use a T/F indicator within the Menu Selection (user)
    Event to access another Event. For example, within the Menu Selection
    (user) Event, I placed a boolean named X and can turn it on with a menu
    selection. Now, make a new Event Structure to look for X Value Change -
    doesn't work.
    Message Edited by Broken Arrow on 11-30-2005 10:24 AM
    Richard

    I use one event, Menu Selection (user). to trap all of my menu events.  Use Item Path and / or Item Tag to figure out what menu item was selected then branch code based on selection.  Wtih Booleans and menus you need to update the state of the boolean on the menu by setting it True or False.  It doesn't automatically toggle like you would expect.
    Matt
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
    Attachments:
    menuSelect.JPG ‏45 KB

  • Use event structure and while loop in parallel

    Hello, I would like to use an event structure in parallel with a while loop. I have a camera that needs to constantly take pictures and I have that setup in the while loop. I also however need to do other functions in conjunction with the picture taking. I have about 50 or so events that need to have access to while the pictures are taken. Is there any way to do this? If not is there any way to have a global stop variable that is attached to all 50 of the events. I know I can do this the hard way and have each boolean event in the event structure be attached to the while loop stop control. This is however very inefficient. I would also like to know if I can simply use a mouse click as the stop of the while loop. Am I able to have a variable that goes from false to true on mouse click without using the event structure to do this? Thanks.

    Yes, just place the event structure in a second while loop.
    Add a stop button to the other while loop and add an event for the stop button to stop both loops. For a simple example, see my VI posted here:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=176367&jump=true
    Simply add more event cases as needed.
    LabVIEW Champion . Do more with less code and in less time .

  • Buttons stay pressed when using event structure

    I have an event structure in a while loop to handle various buttons the user can press.  I used this instead of case structures on the buttons because I have some advanced events I want to happen to the controls as well.  Code wise it is working fine, but the buttons are not release when you press them.  They only change once when pressed.  So if they are released and you click them they stay pressed.  If you click on them again, they release.  This is very ugly.  What am I doing wrong?  I have tried changing thier type to switched vs latched and it makes no difference.  I tried changing the event on them as well and that doesn't seem to matter.  Currently I have "mouse released" on the button as the event trigger.

    Hello Muffin,
    If you have the buttons configured for "latch" operation (reset after being read, which sounds like what you want), the button will only reset when it is actually read within the code- are they connected to anything or read somewhere within your application?  The simplest way to ensure the buttons are read when the event is triggered is to place them within the mouse-up event.
    Regards,
    Tom L.

  • Use Event Structure to trigger a 1 off event

    I am trying to use an event structure to trigger a 1 off event.  I thought that I could check for the condition that I want to trigger the event and wire this the Val(signaling) property of a Boolean.  I then created a Value Change event on this control expecting the event to trigger when the value changed from false to true.  what I find is that writing to the Val Signaling property triggers the event every time not just when the value changes.
    The attachment is a simple vi to try and illustrate this point using the iteration counter to try and trigger a 1 off event on the 10th iteration.  The Boolean 'Once' changes from False to True on the 10th iteration but the event is triggered for every iteration.  Need to run in debug
    Any Help much appreciated
    Ken
    Solved!
    Go to Solution.
    Attachments:
    1 off event trigger.vi ‏12 KB

    One thing that I should have pointed out. I don't know what you are
    going to do in your "one off" event. If it is a time consuming operation
    you should not use an event but send a message to another loop and have
    that loop execute the code. Otherwise your event loop will be blocked.
    You can send messages to other loops in a
    number of ways. Variables, Queues, Notifiers, Action Engines, etc..
    Attached
    is your vi modified to use a notifier. I also modified your conditional
    logic. You said you wanted to have something happen only once but you
    were using a less than comparison. I changed that to an equals comparison so that when i = 9 a notification is sent to a slave loop.
    A message box will be displayed on the tenth iteration of the master
    loop. Notice how your numeric indicator continues to increment even with
    the dialog box displayed. That would not happen if the dialog box were to be displayed in the master loop.
    =====================
    LabVIEW 2012
    Attachments:
    1 off event trigger.vi ‏15 KB

Maybe you are looking for

  • I want a ''Page not found'' page on my website! :)

    Hello there, ive got this website http://www.orlandosalsa.co.uk 1) And everytime i browse ''http://www.orlandosalsa.co.uk/images'' i get this: (i know this is supposed to happen but i dont want it to) So I would like somehow to hide this folder from

  • Free filter or/ plug-in set? for "OIL PAINT" - to download & add to Photoshop CS 5 (Mac OSX 10.8) ?

    I have the CS 5 Suite instaled on 2 of my Macs (per Adobe licensing).  I upgraded (aftwrward, in 2012) just the Photoshop CS 5 app to Photoshop CS 6. There is a GREAT filter [then new] with PS CS 6 called "Oil Paint". I hope to be able to find out fr

  • Solaris 9 Install Fails at Console Window

    I am attempting to install Solaris 9 on an Ultra 10. Ran boot cdrom from OK prompt, using the install directory. Got to the selection of language fine, (selected English) CDE started up, and then got a console window. It displays the standard install

  • Two step confirmation

    Hi All Do we have any thing like two step confirmation in Warehouse Management. Thanking you With Rgds Vinod

  • After transparency reduction in preflight text jumps

    Dear All, we are using the adobe acrobat transparency reduction in a preflight. Now we noticed ocasionly we have the problem that Text is Jumping like this: After a few tests i found out that this comes from the transparency reduction (same when usin