Determine index of array within event structure

I am doing some testing with dynamically registered events.  For these testing purposes, I have 2 separate arrays of boolean references hooked up to the dynamic input terminal.  The event structure is executing like I expect it to.  The only problem is that I want to know the index within the array for the event that triggered the value change event.  I would have thought I could use the CtlRef node to determine this, but instead it returns a reference to the actual boolean control that triggered the event.
I could write a subroutine that searches for the label of the boolean that triggered the event within the arrays, but that is not efficient or good practice.
So for instance, if I click on Boolean 2, I'd want the event structure to know it was array #1, index 1.  If I click on Boolean 6, I'd want the event structure to know it was array #2, index 2.
Is this possible?

That is a very good idea.  The caption is good to use for the label you show to the user.  You can change it to show different things, even programmatically, such as if you need to make your application more international and have it display controls in different languages to different users.  It lets you use longer or more descriptive names, without having those long names eat up block diagram space.
Another thing I've done is take the control reference and search for it among the array of control ireference.  Search 1-D array will give you the index of the control within the array.  Then I can use that index and apply it to a different array and index out a value from that.  It could be a name, or perhaps a numeric value I use as a multiplier or something like that.  Just make sure there is a one to one correlation between the references in the array and whatever is the other array you are getting additional data from.  For what you have drawn now, it could be a little bit complicated because you actually have two different 1-D arrays of references.  But if you concatenated those arrays together, you'd have a single 1-D array you can search.

Similar Messages

  • How to determine the execution order of event structure

    Hi everyone,
    I have an event structure were it contains four events. All the four events has separate buttons to execute. Here, three events will generate numeric output, remaining one event (Finder) should find the order of those three events. For example, Three events namely A, B and C. I execute the events in the order of B, C and A. The finder event should find the order of previously executed events(B, C and A). 
    Thanks in advance.
    Solved!
    Go to Solution.

    Hello Vij@y,
    I could not look in to your VI because I dont have LabVIEW 2013 (I have 2010) but i tried to understand the situation you are explaining.
    Please find attached image of front panel I made for your reference.
    Here I generated two events sequently, no 3 first followed by no 1 and the same is displayed in sequence array. now you can use the build array function to actually add each event to this array as explained by many people in this forum.
    regarding the timeout event, either you can display the sequencer array in that event or you can display it in finder event and then you can reset the sequencer in finder event (I used reset button click event to reset sequencer back to zero value)
    regarding getting zero when you press finder/reset button before triggring any other event:- Is it not correct to have empty array when you have not trigger any event?
    I hope I put it well and may help you to find solution. 
    With Regards
    Miraz
    Kudos is better option to thank somebody on this forum
    Attachments:
    Sequence.png ‏70 KB

  • While loop with stop button within event structure locks up front panel.

    I am not sure if this is a bug with my program or a bug within LabVIEW.  If you believe that this is a bug with my program then I will post my program to be looked at.
    The problem I am having is there is a while loop within an event structure that fires when a particular value changes.  Once the "Activate" button is pressed the while loop within the event structure starts going with a polling frequency of 1hz (1000ms wired to the "wait till next ms multiple" vi).  There is a "Deactivate" button that is wired to the stop control of the while loop and an outter while loop that resets the event structure so that the activate button is being listened to again.
    Once inside the while loop, however, none of the button are responsive within the front panel.  The VI continues to run, and only 60% of my CPU is being consumed, but none of the button or scroll bars work.  The only way for me to terminate the program is with the "Abort" button next to the "Run" button.  If I remove the event structure so that the while loop in question runs as soon as the program starts, the front panel remains responsive.  I've inserted probes within the while loop and verified that it is not running prior to the "Activate" button being asserted, and it is running after the assertion of the "Activate" button with the expected polling frequency set by the "wait till next ms multiple" vi.
    Can anyone help?  Do I need to post my code?
    -Nic

    It is typically not a good idea to stall an event structure by placing loops inside event cases. What good is an event structure if it is not free to repond to events?
    Have a look at some alternative solutions, such as in the following link:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=224817#M224817
    LabVIEW Champion . Do more with less code and in less time .

  • 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

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

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

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

  • Event structure to detect value change of a control within a cluster in an array

    I have 1D array that contains a cluster. The cluster contains a numeric and a boolean control.
    If the user starts to edit the numeric control value i would like to call one subVI, and if the boolean control value is changed, call a different subVI.
    The array control on the front panel allows the user to edit a number of the array elements. 
    I would like to use an event structure to detect a value change in the cluster. When editing the Events, in the Event Sources panel i get the option to select only the array, not the cluster within the array or the controls within the cluster. Can the Event structure be opened up to show controls within clusters and arrays?
    The solution i am using is to detect a mouse up event on the array and then use property nodes to  determine if the key focus is on the numeric, and  a case structure to determine which subVI to call. This works, but is there a better (simpler) way?
    Thanks, Blue.

    Thanks for the responses guys.
    The tricky bit was that i wanted the numeric control values to flag they were going to be edited, so i could call a subVI, before their values were changed by the user. This is done by using the key focus property node, - i need to detect changes on the fly rather than post the event.  Probably didn't make this clear enough in my original post. 
    The array is of variable size depending on if the user decides to insert or delete elements. The user also has the option to click and edit the array without having to do to much scrolling through the array index, as the FP shows several elements at a time. The Event Structure does a good job of automatically determining which element in the array is being edited, and returning those values to the property nodes. Turned out simpler than i thought it might be at one point!
    Cheers, Blue. 
    Message Edited by BlueTwo on 01-15-2009 06:52 AM
    Attachments:
    evstrct1.jpg ‏63 KB

  • I need help with event structure. I am trying to feed the index of the array, the index can vary from 0 to 7. Based on the logic ouput of a comparison, the index buffer should increment ?

    I need help with event structure.
    I am trying to feed the index of the array, the index number can vary from 0 to 7.
    Based on the logic ouput of a comparison, the index buffer should increment
    or decrement every time the output of comparsion changes(event change). I guess I need to use event structure?
    (My event code doesn't execute when there is an  event at its input /comparator changes its boolean state.
    Anyone coded on similar lines? Any ideas appreciated.
    Thanks in advance!

    You don't need an Event Structure, a simple State Machine would be more appropriate.
    There are many examples of State Machines within this forum.
    RayR

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

  • Stuck with making my event structure examine if two arrays are equal

    Hi there, I'm new to labview. I'm trying to write an event structure; examining if one array equals another array. The program will carry on if they are equal, otherwise it will continue checking... Any help is appreciated.
    My program is attached.. It is eventually going to be a memory game when I get it working..
    Sequence 1, case structure 10 is were I'm stuck with the case structure.
    Thank you in advance
    Attachments:
    attempt 2.vi ‏18 KB

    Seems to me like you should implement a true State Machine.  This way you can repeat states and/or jump states as needed.
    State Machine
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Array of buttons and Event Structure

    I have a the same problem... I was wondering if you were able to find a soln.
    I have literally thousands of buttons and each button as a unique key code and unique name.
    For Example :  
    Button Name    – Key code #
    PUSH              - 1
    POP                 - 2
    PULL               - 3
    The way I program this simple algorithm is deadly painful. 
    1)      I create 1000 buttons by going to control->buttons.
    2)      Then I have to go through one by one to change the Boolean text to “PUSH,POP,PULL…”  
    3)      Then used the Event Structure, adding in all the controls names “PUSH, POP, PULL..” In side each event, I placed the key codes “1,2,3..”
    I have search and tried for weeks to find a better way, and still nothing comes to mind.  
    Please help.

    Hi Ben,
    Thank you for your reply, I have attached my try_code and a picture of the code I currently have.  I  am new in Labview, but I am confident that, there must be a easier way to make an array of buttons with different button name and an associated number to that button.  
    The 1st file, is to show you want I am currently doing, (painful)
    The 2nd file attached is some of the things i tried, I had great hope with my try_code, array_jan25.  But I couldn't get it.  I think I am very close.
    Thanks again,
    Attachments:
    ThePainfulWay.doc ‏63 KB
    Array_jan25.vi ‏42 KB

  • Event Structure's value change, not detecting changes when tabbing thru array of clusters

    Hi!  I have an array of clusters (int, int, string, int) control, and want to detecting changes made to the it.  I used the Event Structure's value change case on the array, it works excellent except that it'll only detect the changes when you click out of the element or press the enter key (the one by the numbers, not carriage return).  I want it to detect the changes when I tab thru the cluster or array too, but I can't figure it out... Does anyone have any ideas?
    Thanks!

    mfitzsimons wrote:
    altenbach
    Tried Value Change with my example done in 7.1 and it doesn't trgger an event.  That is why I suggested Mouse Down.
    Curious. I did a few minor edits in 8.0 before saving as 7.1, but the simple value change event got triggered just fine when the value vas terminated with a tab in 7.1. Every time.  Strange....
    Are you on 7.1 or 7.1.1? Maybe there's a difference (I am using 7.1.1).
    LabVIEW Champion . Do more with less code and in less time .

  • Can I use an event structure within another event structure

    Hi
    Can use an event structure within another event structure?
    Thanks
    Yasamin
    Solved!
    Go to Solution.

    I attached my Vi from my old project (MY OLD VI). It is worked correctly.
    But I decided that use event structure instead of case structure.
    I attached my new VI as a picture and as a LabVIEW VI too (network_analyzer_8510_920527 Frequency Sweep.vi )
    My graphs show by pressing "case 5: button (Bottom of page right hand).
    Then I want to show each of graph in a large window( in a new VI) by clicking a key (for example "show 1").
    Thanks
    Yasamin
    Attachments:
    my VI.JPG ‏256 KB
    network_analyzer_8510_920527 Frequency Sweep.vi ‏72 KB
    MY OLD VI.vi ‏69 KB

  • Event structure problem in updating array

    Hi, i have a problem with my .vi...
    i have an array of 10 boolean i want to modify by pressing SET TRUE or SET FALSE buttons, after selecting (with the ring selector) which is the elemente that should be changed...
    there seems to be something strange in the behaviour... the array is not correctly updated... maybe there a big mistake i cannot find...
    i  hope you could help me
    tks
    Attachments:
    array_modify.vi ‏18 KB

    The problem is the the Ring control is read before the event structure, so it return "old" data when you click of either SET TRUE or SET FALSE.
    You need to move it so that it is read inside the event structure after you click on one of the "SET" buttons.
    Create a local of the Ring for one of the SET events and move the Ring terminal into the other.
    Or create a blank event for the Ring control so that it will update the input tunnel going into the event structure.
    Or create a single event to handle both SET TRUE and SET FALSE.
    Omar
    Attachments:
    array_modify.vi ‏9 KB

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

Maybe you are looking for

  • Can't remove malware toolbars

    My husband stupidly accepted all downloads and now he has malware toolbars. I've tried everything I can find to remove them, but can't get rid of them. They do not show up under Control Panel - Uninstall or Firefox - Addons or Firefox - Extensions. I

  • How do you display a parameter form built from a report?

    Does anyone know how to display the parameter form from building a customized report, as a portlet on a page? Everytime I try, I get the report, which will return no records because it does not first ask for the query parameters. thanks! null

  • Why Does CS 4 Do This?

    !. PS 7 would zoom to the same extremes at CS 4, but  the result would be CLEAR and easy to make changes. CS 4 shows big pixel squares at only 600! Why? 2. PS 7 would lock a layer when I wanted it locked. But I have several times in opening files in

  • Converting to Core from Asio

    Hi. When I try to open old projects on my intel-mac I have to convert from asio to core but everytime Logic 8 shuts down. It´s also the same in Logic 7. Anyone who knows what to do?

  • BAPI_GOODSMVT_CREATE - position within material

    Hi guys, i use the function BAPI_GOODSMVT_CREATE for gm_code = '05'. i fill the fields: on header level:     bapigmhead-pstng_date = ls_post_date-pstng_date.     bapigmhead-doc_date = ls_post_date-pstng_date.     bapigmcode = '05'. and then on item l