Dynamic user event

Hello, I am a newbie regarding dynamic user events.
Basically, I want to create a user event that triggers  an event structure in a subvi.
To do this, I wire up a "create new user event" and then pass the refnum to my subvi "more info" as seen below.  But this piece of code get's stuck in the sub-vi and never leaves :[
here is my subvi below:
I'd greatly appreciate any help :]

To stop your main vi you will need to provide a mechanism to stop your sub vi.
I would use an additional boolean User Event to do this.
(This could be shared among other subvis).
When the (let's call it) Shutdown event is received, set your subvi while loop control terminal true.
Note: When using this scheme in an exe file, if the subvi front panel is open and you shutdown the main vi, the subvi can remain open. This happened to me using LabVIEW 2010. I had to use a Front Panel Close Method to avoid this issue.
When using the Front Panel Close Method you should first check if the front panel is open or not to avoid an error.
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.

Similar Messages

  • Dynamic user events freeze user interface

    Hi all,
    I am having problem with dynamic user events.
    Dynamic user event is registered to the event structure, and many dynamic user events come in very fast, about every 30 ms. It freezes up the user interface, no response to mouse and keyboard, even after all user events finish execution.
    Any idea or work around?
    Thanks for any help.
    Anne

    Hi Anne,
    > Dynamic user event is registered to the event structure, and many dynamic user events come in very fast, about every 30 ms.
    The 30ms rate is not unreasonably fast as long as the processing for the event(s) can be completed in less than 30ms.
    What tasks are you doing in the User Event?
    For tasks that may take time to complete (like logging) you could queue up the data and send it to a consumer loop.
    > It freezes up the user interface, no response to mouse and keyboard, even after all user events finish execution.
    My *guess* here is that you got stuck in an event that never completed.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • Xcontrols and dynamic User Events

    Hi all,
    I'm trying to build a XControl with an Event Structure that accepts User Events generated by a separate parallel loop on the block diagram.
    A monitoring loop with its own Event Strucure on the block diagram seems to handle the User Events generated by my producer loop but the XControl seems to ignore the User Events.
    Example LabView 8.5.1 project is attached
    Any ideas?
    Attachments:
    XControl.zip ‏75 KB

    Hi Anne,
    > Dynamic user event is registered to the event structure, and many dynamic user events come in very fast, about every 30 ms.
    The 30ms rate is not unreasonably fast as long as the processing for the event(s) can be completed in less than 30ms.
    What tasks are you doing in the User Event?
    For tasks that may take time to complete (like logging) you could queue up the data and send it to a consumer loop.
    > It freezes up the user interface, no response to mouse and keyboard, even after all user events finish execution.
    My *guess* here is that you got stuck in an event that never completed.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • Crashing LabVIEW with dynamic user events

    Hello,
    we are able to execute the attached sample with a german LV 8.2.1 on a Pentium 4 2.4 GHz PC with 1GB Ram and W2K SP4.
    However we seem to have problems on a faster machine with an english Windows XP Server but also LV 8.2.1. Could this please be verified?
    So start the test, first manualy load the "Button Menue 13.vi", then the "Button Wrapper 13.vi" and finally the "Button Receiver 13.vi".
    After this activate "Button Menue 13.vi" and let it run for a short while. After softly stopping "Button Menue 13.vi" with the local "Stop"-button, all VIs should indicated the identical amount of received dynamic user events.
    On our local PC we can run sucessfully and quickly to e.g. 10000 events and more.
    Attachments:
    ButtonTest13.zip ‏52 KB

    Hello,
    after disabling hyperthreading in the BIOS the english XP Professional and the examples now run nicely!  

  • Missing dynamic user events across VIs

    We have a sub-Vi Statemachine.vi, which has its own event structure with a 5ms time-out, everything enclosed into a loop.
    This sub-VI is called repeatedly from the main application with command lists to execute. This can be a longer list or e.g. an empty list.
    It turned out, that we can miss successfully sent events, despite the documented internal queues.
    Placing the event structure into an added parallel executing, non-terminating loop in the sub-VI seems to help.
    Is there a link to further informations about this behaviour? We are using a german LV 8.2.1.

    Martin,
    I don't know of a good document describing the use of the user event in the way the you and I are using them.
    I've learned from bits and pieces lying around and my collegue. After using it for two years now I have a framework in which the use of user events is relatively easy.
    I know this doesn't help you a lot, but I know that if get the hang of it, it will provide a good and usable architecture.
    I hope the attachments helps you a bit. It is the way I define user event for inter process communication. It will get rid of a lot of wiring.
    Kind regards,
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)
    Attachments:
    Event buffer.zip ‏13 KB

  • Event Handler/Cr​eate User Event bug

    This is a problem I've run into a few times on my system (Win2k) so I finally went back and reproduced it step by step since it wasn't too hard. It causes LabVIEW to crash and exit without saving.
    - Create an Event Handler
    - Place 'Register Events', wire output to dynamic event terminal
    - Place 'Create User Event', wire output to 'Register Events'/User Event
    - Place an Empty String Constant [""], wire to input of 'Create User Event'
    - Set empty string property -> Visible Items > Label = True
    - Rename label from "Empty String Constant" to other such as "Event"
    OR
    - Create a cluster constant with something in it
    OR
    - Place a boolean constant
    - Set boolean property -> Visible Items > Label = True
    - Name label something su
    ch as "Event"
    - 'Add Event Case...' to the Event Handler, select Dynamic / : User Event
    - Delete the constant wired to 'Create User Event'.
    - Place a constant of a different data type and wire it to the input of 'Create User Event'
    LabVIEW immediately disappears (all changes are lost) and this error is displayed:
    ================================
    LabVIEW.exe has generated errors and will be closed by
    Windows. You wlil need to restart the program.
    An error log is being created.
    ================================
    If there is a more appropriate place to post things of this nature that don’t really add to the discussion group, but need to be brought to the attention of NI, please post a URL or submittal method. Thanks...

    Thanks for the detailed request. We are aware of this exact issue, and the problem was actually fixed for LabVIEW 7.0 for Mac/Unix. Unfortunately, it did not get fixed for the initial release of LabVIEW 7.0 for Windows, but we have plans to include the fix in the first LabVIEW patch for 7.0.
    Also, the Discussion Forum is great for notifications of this kind. For future reference, you also have the options of emailing NI engineers directly, or calling us with suspected bug fixes, if you would like more direct communication.
    Thanks again, and have a great day!
    Liz Fausak
    Applications Engineer
    National Instruments
    www.ni.com/support

  • AE user event error

    Have an AE which has errors:
    Init - registers dynamic user events and Runs VI.
    Write - Attempts to generate user event to write data to VI which is running (Error 1)
    Close - Attempts to retrieve control value (safety cluster_out) from running VI and then close (abort).
    The VI gets to run but the generate user event produces an error.  I can't figure out why and I doubt this is the proper way to be doing this.

    Hi Battler,
    I see that you've created the user events, but registering them involes the Register for Events VI, which is located in the same palette. It looks like a property node but has a satellite icon in the heading. It's very possible I'm missing something. Could you post your main and subVIs so I can take a look at them?
    Pardon the messy snippet.
    I have another question, too. It looks like you're closing the reference to your subVI in the init frame. Is there a reason this needs to be done?
    Verne D. // LabVIEW & SignalExpress Product Support Engineer // National Instruments

  • VISA Wait on Event User Event

    I have a Producer/Consumer program that uses an Event Structure to handle the UI button presses.  I want to be able to use the VISA wait on Event to read characters from the RS232 port.  So in my Event Structure I created a case for dynamic user events.
    I also create a while loop that has the VISA Enable Event and VISA Wait on Event in it. I enabled the "Serial Character" event only.  When I get this event I use the Create User Event.VI and Register for Events to get a Event Refnum
    How do I get the Event Refnum from this loop into my Producer loop?
    Solved!
    Go to Solution.

    Paul_Knight_Lockheed_Martin wrote:
    Here is the code
    No, that is not the code. That is one subVI and a picture. Where are you waiting for the VISA events? Where are you generating your user event? Based on the picture you are calling the Initialize_Controller_Communication and remaing in that code until the Stop buuton is pressed. You will not start your event structure in the producer loop until this VI completes. So, if you are not hitting the stop button to complete your initializtion it is no wonder you are never seeing your event structure run.
    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

  • Making an array of different user events refnums?

    Hello all,
    I have a question about dynamic user events. I have 6 different users events which I create, and would like to put into an array. (Such that I can use them in a For loop laters, taking off one event per loop and assigning it to a control of a vi) So far I haven't found a way of doing that since if I just wire the user events refnums to an array I get broken wires. (Similarly if I wire them to a build cluster structure.)
    I think that you'll understand what I am trying to do if you look at my labview code in the attached vi.
    In the vi I create some user events, and then wire them to the control of two vi's which will communicate to each other using these events. In the code you will see 6 Invoke Node structures where I use the "Ctrl Val.set" to pass the events to the two vi's. Obviously this is the wrong why of doing things. Since if instead of having 6 events I had 100, then I would need to put 100 Invoke Node structures on the block diagram (making it very large compared to the size of my computer screen!). 
    So what I would like to do, is put the user events refnums into a array, then put the one Invoke node structure into a For loop, and index the array to assign the events to the vi's programmatically. 
    Is there anyway of doing this? Or is there an alternative (/ better way) to what I have done?
    (Baisically I have 2 vi's that run in parallel and communicate to each other using user events. I need to pass the events to both vi's, how do I do it in the minimum of mouse clicks, and minimum of screen space.)
    Thank you!
    Paul.
    Solved!
    Go to Solution.
    Attachments:
    CameraTempControllerRunner.vi ‏49 KB

    I haven't created any new messages since the forum changed over, so I'm not sure.  But check on the menu under Options on the upper right.  I think there is a way to undo your choice and put it on another.
    Kudo's have replaced the stars.  Anything that was 4 or 5 stars is now equivalent to a Kudo.  But with the old system, anything less than 5 stars was essentially a negative opinion in the ratings.  So to simplify the multiple shades of gray (1 through 4 stars essentially being some degree of a negative) and to just eliminate the negative aspect altogether, the Kudo system was born.
    I don't know if the "Accepted Solution" designation does anything to help the person whose solution was accepted, but having that designation helps people searching the forum because they have the same problem find the answer quicker.
    Message Edited by Ravens Fan on 10-06-2008 10:15 AM

  • User Events Generation - TicTacToe

    Hey everybody,
    In order to get a better understanding of how the event structures are used, I have been playing around with making a tic tac toe game (ironically, i did not know that was a coding challenge until I just started this thread). 
    Anyways, the way I'm doing it is by dynamically registering a mouse move event during mouse down on a boolean control (your game 'marker').  Then when the control is moved overtop of an activex container the boolean lights up.  Right now, however, it only works for one of the game pieces ('Dot 8').
    My question is this, can someone please show me how to create a user event?  I want to create an event where when any boolean control's position is within the bounds of the activex containers it will light up.  I could do this manually with a whole lot of logic (you'll get the idea if you check out the code) but that is rediculous and wouldn't help my learning exercise at all.
    Thanks so much for the help!
    Jonathan
    (Code is attached)
    Attachments:
    events.vi ‏107 KB

    If you want to look at the code of my interface posted HERE, See attached (LabVIEW 7.1). It uses simple mouse-down events on the array indicator to determine where to place the correct piece.
    Enjoy!
    (Disclaimer: The code is not fully tested and documented. There could be bugs There is also room for improvements)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    TTT-Trainer3.zip ‏2139 KB

  • Help needed, Createing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?messageID=9953193

  • Help needed, Providing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }Edited by: Roger on Nov 3, 2007 11:50 AM

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?threadID=5233033&messageID=9953169#9953169

  • Producer Consumer Subpanels, User events and DAQ

    Hello All,
    I am working on a Producer Consumer application and have beed looking at subpanels for user navigation. The application needs to be capable of responding to user generated events but also manage data received from attached data acquisition and control hardware. This is a 2 part question.
    I need to implement about 15 screens in this application and have started integrating subpanels. I need to be able to navigate from one subpanel vi to another using subvi buttons but dont understand how to build this functionality. Can I build functionlaity so that when I click on a subpanel loaded vi's button it will load the vi referenced by that button and the original dissappears.
    I have a 3 loop producer event template consisting of (1)data acquisition producer, (2) user event producer and (3) consumer loop but theres not much detail, are there any reasonable templates out there? I have seen the data- consumer and user-consumer but no mix of all 3.
    Advice appreciated
    Chris

    I use subpanels to host my display vi's and control them dynamically.  I would have a loop or vi process that manages your subpanel.  You could use user events, queues or notifiers to send messages to this subpanel manager to perform the basic functions such as loading a vi into a subpanel, removing a vi from subpanel (you can remove and stop the vi or keep the vi running in the background or even make it a floating vi.)  A subpanel button can create a local event which in turn could trigger a user event or message to the subpanel manager.  I have attached my subpanel manager to give you some ideas...
    Attachments:
    Subpanel Manager.vi ‏39 KB

  • How to make a simple control value comparison a user event?

    Hey everyone,
    I am trying (with no luck) to figure out how to make an event out of a simple control comparison without having to put the controls inside a while loop to be polled or in the event structure.
    For example; how do I make an event when 'numerical control 1' equals 'numerical control 2'?
    I know that I could have these inside a while loop with the event structure and then wire the comparison to a boolean, then reference the boolean's value change event.  But rather, I would like to create an event for the comparison without the boolean and outside the while loop such that the loop doesn't have to run through the comparison each time, and doesn't have to poll the controls and bool.
    Thanks for the help

    Attached is a simple user event structure that I was thinking about.  Using this you can decouple the control from the comparison, it just works on valye comparisons.  Since it uses the event structure there is no polling and is very CPU friendly.  I have allowedfor the comparison to be linked to the "Value 1:value change event" and the compare button true event.  I hope this is what you were looking at.  Also since it is a user event which is dynamically registered you can register/unregister it at will durring execution making it a flexable event handler.  It might be alittle buggy because I have spent about 3 minutes developing it (particularry when passing values into the event structure there might be a state issue from the data flow so local variables are a better choice)
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA
    Attachments:
    CompareEventvi.vi ‏49 KB

  • LV 7.0 extremly unstable while working with user events during edit time

    hi
    i create and register several user events inside an initializing vi and then pass the registered events to the event structure using dynamic events in my top level vi. all works fine untill i do some changes to the registered events, e.g. changing names, datatypes or add/remove some events. when doing so my LV 7.0 chrases after opening the top level vi (exception error, no *.cpp errors). all changes i made are going to nowhere. i understand that after the changes i made the registered events in my init.vi-indicator dosn't match the events in my event structure, but i can't understand that LV chrashes.
    here are my questions:
    1. is it a known problem to LV 7.0?
    2. should i reinstall LV 7.0
    (i have LV 6.x and 7.0 on my machine)?
    3. is there a fix?
    thanks in advance
    greetings
    chris
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

    Hello Chris,
    I have been looking into your problem and have come across one possible known bug in LV 6.1 that may be showing itself in 7.0. If modifications are made to the typedef of a registered event the vi will crash. I was hoping that you could post a small piece of your code and instructions on how to reproduce the crash. This way I can see if this is the same bug, a programming error, or an installation error. I can then determine if there is still a bug that needs to be looked into by our research team.
    Thanks,
    Caroline
    National Instruments
    Thanks,
    Caroline Tipton
    Data Management Product Manager
    National Instruments

Maybe you are looking for

  • Google Play and Google Services errors on Moto E

    Hello,  I have a Moto E phone which has recently stopped working properly. I keep getting error popups saying 'Unfortunately, the process com.google.process.gapps has stopped' , 'Google services has stopped working', 'Google play has stopped working'

  • Get Local currency - PO creation

    Hello, I am creating a PO and giving inputs-- >Vendor, Pur Org, Pur Grp,Company Code, payment terms, incoterms. I am developing a badi which will calculate exchange rate based on Currency. I need to get local currency in order to calculate exchange r

  • MBP15/17 2007 week models info

    I have gone through about 6 macs in the last year. The first one being a mbp15, from about this time last year. That one had all the overheating, mooing, etc problems. After that one got stolen I got a macbook, which was actually a pretty good unit.

  • How to make SAS Server or datasets entry in tnsnames.ora

    Hi, I want to make an entry in tnsnames.ora for SAS Server or SAS datasets. Can anybody tell me what all attributes is requried? Regards, Vikas

  • MS Word 2013 unable to start. "Sorry, something went wrong and word was unable to start. (6)

    I am trying to open MS Word 2013. I have purchased the MS Office online and pay a subscription. When opening MS Word, it comes up with the error message "Sorry, something went wrong and word was unable to start. (6)" This appears to be happening with