Event Handler with Internal Loops

Hi...
I'm trying to update a basic program to handle control events more efficiently.  The program needs to perform the following functions on start button press:
1)  Import data file and parse instrument settings from multiple (X) rows
2)  Perform loop with case for each row changing input settings, the read test equipment, and store data in new output data file
I've looked at producer/consumer example and the continuous measurement and logging example, but not sure if either (or none) of the following two options is the best way to handle the looping from the file...
A)  Use events to trigger looping for all input cases within a consumer (I've had a problem with this due to not being able to terminate the loop within the consumer with an abort button)
B)  Make the consumer only a single data acquisition and load loop inputs as queues and generate output queues to be handled by another parallel logging loop
Any advice?

Hi bripple,
Based on what you've described above, a Producer/Consumer Design Pattern (Events) might work. There is a template for this design pattern that ships with LabVIEW which you can access by going to File > New > VI > From Template > Frameworks > Design Patterns. When the user clicks the start button on your front panel, you can queue up a command that will trigger your consumer loop to read the file and loop over each instrument setting. Within that loop, you should be able to queue up additional events corresponding to each instrument setting and reading.
In terms of error handling, you can conditionally stop a loop if you detect an error. If your user decides to push a button on the front panel to stop the entire process, you can use Enqueue Element at Opposite End to put a stop command at the beginning of the queue. When your consumer loop encounters this event, it can flush the queue and do any cleanup it needs to perform.
One additional thing to be cautious of is that queues can only handle one data type. Because of that, you may also want to consider a Queued Message Handler design pattern. This design pattern allows you to send both a command and data along with that command. I think that would be ideally situated for you since you could send a "Read Instrument" command along with the data for its settings. You can access this design pattern from within LabVIEW as well. If you have LabVIEW 2012 or LabVIEW 2013, see these instructions. The things I've said above also hold true for the Queued Message Handler as well.
Let me know if you have any questions or if this is helpful.
Regards,
Matthew B.
Applications Engineer
National Instruments

Similar Messages

  • C# control event handling with javascript

    How can I get javascript to execute for "onchange" / "OnSelectedIndexChanged" event instead of a CodeBehind method? I think "OnSelectedIndexChanged" event has to be handled by CodeBehind; but how can I replace that (or onchange) with
    a javascript event handler?
    I have the following in my xyz.ascx file:
    <asp:DropDownList ID="ddlTypeCar" CssClass="BatsRefAddressTypes" runat="server"
                      onchange="javascript: testAlert();"
                      OnSelectedIndexChanged="ddlTypeCar_SelectedIndexChanged"
                      AutoPostBack="True" />
    I could not get the javascript to execute, even though I removed OnSelectedIndexChanged="ddlTypeCar_SelectedIndexChanged" and/or set AutoPostBack="false".
    Additionally, I tried added the following in xyz.ascx.cs Page_Load() method.
    ddlTypeOfAddress.Attributes.Add("onchange", "javascript: testAlert();");
    which didn't help.
    Thanks for your help in advance.

    Hi,
    you can control client events instead of server events with javascript
    look this url for more information
    http://www.w3schools.com/js/js_events.asp
    Regards

  • Registering event handler with preloader

    As you can see from the code below, I have an application
    with a custom preloader designated in the Application tag.
    I would like the preloader to be able to receive a message
    from my main application but in order to that I need to register a
    method in the preloader as an event handler for an event fired by
    my application and in order to do that I have to have a reference
    to both the preloader and the application.
    Where can I get a reference to both? this.preloader seems to
    be null when the initialize() event is fired in my application and
    mx.core.Application.application is null in my preloader. Is there
    any way at all to do this?
    I would GREATLY appreciate any help with this! I've been
    struggling with this for hours :(
    Thanks!
    Moshe

    Thank you Nayan..
    BR
    Aliye

  • Event Handling with Java API.: Adding to a hierarchy table throws 2events

    I´m having some problems with the event handling. I´ve registered a Class with extends AbstractDataListener as EventListener. When there are changes in the product hierarchy table, some extra work should be done. However if i add a new record into the hierarchy, two events are fired.
    DEBUG DataEventListener.java:123 - Added:Development;PRODUCT_HIERARCHY;R17;Getra?nke, SEW
    DEBUG DataEventListener.java:123 - Added:Development;PRODUCT_HIERARCHY;R17;32 Zoll, B&R
    DEBUG DataEventListener.java:123 - Added:Development;PRODUCT_HIERARCHY;R18;56 Zoll, Lenze
    DEBUG DataEventListener.java:123 - Added:Development;PRODUCT_HIERARCHY;R18;20 Zoll, allgemein
    In this case, i added the records "32 Zoll, B&R" and then "20 Zoll, allgemein". As you can see in both cases two events are fired and the first event seems to come with wrong data. The reported id for the newly created record is R17. For the logging, i did lookup the entry in the hierarchy table by id and use the displayvalue of the record. But the first event always shows the displayvalue from some already existing entry.
    How can i avoid duplicate events or if this is not possible, how i can recognize that the display value of the first event is not valid.

    I have not tetsted it yet, because I'm waiting for my server to be updated, but SAP told me that the API version 5.5.42.67 should fix the problem.
    Thanks for your post.

  • Event handling with JSF

    Hi Everybody,
    I have a question about event handling and I am just wondering if I can do the following with JSF.
    I have two HTML dropdown lists A and B. When ever a value changes in list A, based on the selected value, list B has to be populated. Is it possible to do with JSF? Can you guys give me pointers where some code samples may be available?
    Cheers!
    Krish

    Take a look at the JSF Value-Changed Listener sections

  • Event handling with button

    Hi All,
    I am trying to write an event handling on my button, but i seem dont know where to start from. My code are below:
    import java.net.*;
    import java.io.*;
    public class ReadWrite
    public static void main(String[] args) throws Exception {
    URL myLocalhost = new URL("http://localhost/Write.pl");
    URLConnection myURL = myLocalhost.openConnection();
    BufferedReader myBR = new BufferedReader(
    new InputStreamReader(
    myURL.getInputStream()));
    String inputLine;
    while ((inputLine = myBR.readLine()) != null)
    System.out.println(inputLine);
    myBR.close();
    I want to write a code with a button to run the above code.
    Could you please advise?
    Thank for any consideration you may give me.

    here's the code to read a file, modify for your url connection
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    class Testing extends JFrame implements ActionListener
      public Testing()
        setLocation(400,300);
        setSize(200,100);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
        JButton btn = new JButton("Read/Write");
        btn.addActionListener(this);
        panel.add(btn);
        getContentPane().add(panel);
      public void actionPerformed(ActionEvent ae)
        BufferedReader myBR = null;
        try
          myBR = new BufferedReader(new FileReader("Test.txt"));
          String inputLine;
          while ((inputLine = myBR.readLine()) != null)
            System.out.println(inputLine);
          myBR.close();
        catch(Exception e){e.printStackTrace();}
      public static void main(String args[]){new Testing().setVisible(true);}
    }

  • Event Handler with parameters

    I am to create a generic event handler ro process XML
    returned from the server. Its name is this code is "loadFormData".
    Here is my code:
    var params:Object = new Object();
    params.requesttype = 'send';
    params.datarequest = 'xml';
    params.methodexecute = 'mProcessFileRequest';
    params.formname = "FileIdAction";
    params.fileid = parentApplication.cboFileList.id;
    var t:loadFileData = new loadFileData();
    xmlModuleData.addEventListener(ResultEvent.RESULT,
    t.loadFormData(ResultEvent, frmGeneral));
    var r:runXML = new runXML();
    r.getXMLData(xmlModuleData, params);
    It would work if I dont send any parameters to
    t.loadFormData. But then it is not a generic solution. Is it
    possible to send parameters to a callback function?
    Thanks

    Thanks Charlie
    Liao
    and congrats to all :-)
    * Charlie,
    is there a new "Auto Spam Filter"?
    [Personal Site] [Blog] [Facebook]

  • Event handling with multiple panels

    Hi there,
    Like many here, I'm very new to this stuff so please bear with me..
    I've been building a gui, using a main "parent" JPanel and several
    subpanels. The main reason for creating subpanels was to help me
    with the layout (someone might let me know if this was a bad idea!).
    Now, all of the subpanels generate events in one form or another. What I'd
    like to do is find out the best way to handle ALL of the events that
    can be generated from my various subpanels from the "parent" panel. Hopefully
    this makes sense :) Could anyone offer any suggestions as to the best way
    to achieve this?
    For example, panel1 is a JPanel contains a slider and a button.
    multipanel is another JPanel that contains 6 panel1's. finally
    the main (parent) panel contains the multipanel.
    So, a program that creates an instance of the parent panel wants to know
    the value that one of the sliders on one of the panels in the multipanel
    has (!). How does it get the value?
    I hope I explained myself! Many thanks in advance for any advice offered,
    dan

    class InnerPanel extends JPanel {
    Vector listeners;
    public void add(SwingEventListener lsnr) {
    listeners.add(lsnr);
    protected void notifyListeners(AWTEvent ev) {
    for (Iterator i = listeners.iterator();i.hasNext();) {
    SwingEventListener lsnr = (SwingEventListener) i.next();
    lsnr.eventPeformed(ev);
    public void actionPerformed(ActionEvent ev) {
    notifyListener(ev);
    Your SwingEventListener will be
    interface SwingEventListener {
    public void eventPefromed(AWTEvent event);
    public ParentPanel extends JPanel implements SwingEventListener {
    public void eventPerformed(AWTEvent event) {
    ... do what is required.

  • Event handling with UIScrollView and it's subview

    Hi,
    I have a UIScrollView and inside it a UIImageView. I have a lot of difficulities to handle the events with these two views. Here is what I want to do:
    If it is a multi-touch event (event.allTouches.count > 2), I want the UIScrollView to handle the event, i.e Zoom in/out and pan. If it a single touch event (event.allTouches.count == 1), I want the UIImageView to handle the event.
    Could you please tell me how to do this?
    Thank you very much.
    ff

    Take a look at the JSF Value-Changed Listener sections

  • Event handling with buttons and mouse

    Hi, Im a beginner in Java...!!!
    I have 4 buttons with me- 2 for color(red,blue) and 2 for size(big,small)..
    How do we divide the frame into 2 panels..one for Buttons and Other for Mouse events...
    Now,if I click on RED button and BIG button..and later click in the Mouse Panel area..I shud get a big rectangle filled with red color..and similarly for small / blue..etc...if a new selection is made..the previous rectangles should remain as they are...
    Im unable to get the implementation...any help will be appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class ButtonPanel extends JPanel
    implements ActionListener, MouseMotionListener
    {  public ButtonPanel()
    blueButton = new JButton("Blue");
    redButton = new JButton("Red");
    bigButton = new JButton("Big");
    smallButton = new JButton("small");
    add(blueButton);
    add(redButton);
    add(bigButton);
    add(smallButton);
    blueButton.addActionListener(this);
    redButton.addActionListener(this);
    bigButton.addActionListener(this);
    smallButton.addActionListener(this);
    public void actionPerformed(ActionEvent evt)
    Color color = getBackground();
    repaint();
    // Paint Method
    public void paintComponent(Graphics g)
    {  super.paintComponent(g);
    class ButtonFrame extends JFrame
    {  public ButtonFrame()
    {  setTitle("ButtonTest");
    setSize(300, 200);
    addWindowListener(new WindowAdapter()
    {  public void windowClosing(WindowEvent e)
    {  System.exit(0);
    Container contentPane = getContentPane();
    contentPane.add(new ButtonPanel());
    public class ButtonTest
    {  public static void main(String[] args)
    {  JFrame frame = new ButtonFrame();
    frame.show();
    }

    can U kindly code it for me....!!!you're getting closer,
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=011033but rent-a-coder is that way ---->

  • Event handling with TextArea

    hi all,
    i'm really new to java programming !
    so, i will be glad for any help that is given by you.
    this is the problem:
    when we add text in to a TextArea, an event should be
    fired. that means, we should capture the status change of the TextArea.
    i tried with: implementing Actionlistener
    ItemStateChanged
    but didn't work !
    any suggestions ?
    thanx
    neo

    Try adding a TextListener.

  • MVC Event Handling with different rows of table view

    When i select a value called ' Herrforth' in the drop down list box of first column first row of the table view, in the form_fields table of do_handle_data i get the following
    name         value
    1 htmlbscrol<0 |
    2 htmlbscrol<0 |
    3 htmlbdoc_i<ComponentTest |
    4 sap-htmlb-< |
    5 tray1-es |1 |
    6 tv1_1_1 |Herrforth |
    7 tv1_pager_<1 |
    8 tv1_rowcou<10 |
    9 tv1_allcol<VORNA/PERSNO/KOSTL/ABTKZ/WERKS/ |
    10 tv1-ts |LINEEDIT |
    11 tv1_visibl<1 |
    12 tv1-chk |1 |
    13 tv1-prevch<1 |
    14 tv1__selec<tv1_selrow_1 | 15 tabstrip1_<2 |
    16 tabstrip1_<1 |
    17 tabstrip1_<1 |
    where 'tv1' is the id of table view. In the do_handle_data now i have written as Nachn = request->get_form_field( 'tv1_1_1' ). " so that the selected value in dropdown is stored in the variable nachn but note that this is when i select the first row first column dropdown listbox. when i select a value in the dropdown list box of 2nd row event name is tv1_2_1. so how will i retrive this value of listbox in 2nd row.similarly when selecting values in drop down listboxes of other rows. In do_handle_event i have written
    WHEN 'tv1_1_1'.
    CLEAR it_table1.
    model->selectempdetails( ).
    it_table2 = model->it_table2.
    LOOP AT it_table2 ASSIGNING <lf_table2> WHERE nachn = nachn ." nachn value i am getting in do_handle_data using Nachn = request->get_form_field( 'tv1_1_1' ).
    wa_table2-persno = <lf_table2>-persno.
    wa_table2-nachn = <lf_table2>-nachn.
    APPEND wa_table2 TO it_table1.
    ENDLOOP.
    DO 10 TIMES .
    wa_table2-persno = ' '.
    wa_table2-nachn = ' '.
    APPEND wa_table2 TO it_table1 . " it_table1 is the table attribute of table view 'tv1'.
    ENDDO .
    ENDCASE.
    Thanks & Regards,
    Renju.

    Hi Ravikiran,
    I am having a tableview in which the first column is an input field.
    I am getting the the value entered in the input field of table view in do_handle_event but note that i am trying to get the value using key board event ('ENTER'.
    How can i get the id of which input field of Tableview i have enterd the value so that i could write in do_handle_event.
    eg:if tableview id is 'tv' and the first column of tableview is an inputfield.
    If i am enering value in first row first column of tableview its id is tv_1_1.So that i could write in  do_handle_event as
    case.
    when 'tv_1_1'.
    endcase.
    If i am enering value in second row first column of tableview its id is tv_2_1.So that i could write in  do_handle_event as
    case.
    when 'tv_2_1'.
    endcase.
    but instead of writing this seperately how could i get the id of inputfield dynamically.Note here the event here is keyboard event 'ENTER'.
    Thanks & Regards,
    Renju.

  • MVC Event Handling with different rows of same table view

    Hello friends,
    I have a tableview with some rows.I have some columns in the tableview.First column contains the drop down list box and other columns are output fields.
    I am allready able to populate the columns according to the selection of a value in the drop down listbox of the same row.
    In the layout of view for the selectionmode attribute of tableview i have given 'lineedit'.
    In the do_handle_event i am also able to get the current selected row of the tableview.
    DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
    selection = tv_data->selectedrowindex.
    Scenario:I have selected the first row then i am selecting a value in the dropdown and able to populate their corresponding value in the corresponding output field of same row.
    So the first row has the selected value in drop down listbox also the corresponding outputfield of same row also has the value.This i am doing by inserting it to the final internal table for the tableview according to currrent selected row .
    Now i am going to select the second row.then i am selecting someother value in the dropdown listbox of the second row and filling the other columns correspondigly.I am able to do this for the secondrow.What i now need to do is i also want to see the first row with slected values correspondingly when the final view comes.ie i need both rows with corresponding values.
    Similarly when selecting third row and other rows so on.
    how to do this?
    Thanks & Regards,
    Renju.

    Hi Renju,
    Try using MULTILINEDIT - this is used when you want to edit multiple rows all at once.
    Cheers

  • Unobstrusive event handling with Spry

    Hi,
    I've got this
    In one of my javascript files I have the function
    function storeCaret(mytext) {
         if (mytext.createTextRange) {
             mytext.caretPos = document.selection.createRange().duplicate();
    In my source I have
    <textarea name="ReplyQuote"  rows="10" id="ReplyQuote" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);">Text in here</textarea>
    Which has various event handlers that I would like to make unobtrusive.
    I've tried
    Spry.$$('#ReplyQuote').addEventListener("change",storeCaret(this),false);
    Spry.$$('#ReplyQuote').addEventListener("click",storeCaret(this),false);
    Spry.$$('#ReplyQuote').addEventListener("keyup",storeCaret(this),false);
    Spry.$$('#ReplyQuote').addEventListener("select",storeCaret(this),false);
    But it's just not returning the correct reference to the function storeCaret.  So I guess my understanding of this needs improving.  How do I ensure I pass the same reference unobtrusively?
    Thanks
    Phil

    Spry.$$
    ('#ReplyQuote').addEventListener("change",storeCaret(this),false);
    that will execute the storeCaret() function inside the observer.. The 
    function should be passed in as reference to the function. (without 
    the () );
    Spry.$$('#ReplyQuote').addEventListener("change",storeCaret,false);
    Will work. the "this" inside the function will reference to your 
    ReplyQuote

  • Event handling with images

    I am not sure how to get my images to respond to the mouseClicked event. I need to know how I can get an image to play an audio clip once it is clicked on.

    I am not too sure how to do that, so I will show you the code that I am using for my DrawingPanel class. I have a MyApp class as the main. I have the part in the mouselistener commented out because it doesn't compile. Please list a suggestion.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.applet.AudioClip;
    import java.net.URL;
    import java.net.MalformedURLException;
    public class DrawingPanel extends JPanel
    private Image goku, trunks, vegeta, gohan, piccolo, background;
    private AudioClip clip1, clip2, clip3, clip4, _clip5;
    private JApplet _app;
    public DrawingPanel(JApplet app)
    super();
    _goku = new ImageIcon("goku.gif").getImage();
    _vegeta = new ImageIcon("vegeta.gif").getImage();
    _gohan = new ImageIcon("gohan.gif").getImage();
    _trunks = new ImageIcon("trunks.gif").getImage();
    _piccolo = new ImageIcon("piccolo.gif").getImage();
    _background = new ImageIcon("DBZ%20wallpaper%202.jpg").getImage();
    _clip1 = app.getAudioClip(app.getCodeBase(), "goku.wav");
    _clip2 = app.getAudioClip(app.getCodeBase(), "vegeta.wav");
    _clip3 = app.getAudioClip(app.getCodeBase(), "gohan.wav");
    _clip4 = app.getAudioClip(app.getCodeBase(), "trunks.wav");
    _clip5 = app.getAudioClip(app.getCodeBase(), "piccolo.wav");
    _app = app;
    public void Play1()
    _clip1.play();       
    public void Play2()
    _clip2.play();       
    public void Play3()
    _clip3.play();       
    public void Play4()
    _clip4.play();       
    public void Play5()
    _clip5.play();       
    public void paint(Graphics g)
    super.paint(g);
    g.drawImage(_background, 0, 0, app.getWidth(), app.getHeight(), null);
    g.drawImage(_goku, 100, 100, 150, 200, null);
    g.drawImage(_vegeta, 350, 100, 150, 200, null);
    g.drawImage(_gohan, 300, 400, 150, 200, null);
    g.drawImage(_trunks, 100, 400, 150, 200, null);
    g.drawImage(_piccolo, 550, 100, 150, 200, null);
    this.addMouseListener(new MyMouseListener(this));
    private class MyMouseListener extends MouseInputAdapter {
    private DrawingPanel _dp;
    private Point _point;
    public MyMouseListener (DrawingPanel dp) {
    _dp = dp;
    public void mouseClicked (MouseEvent e){
    _point = e.getPoint();
    /*if (_goku.getPoint() == _point) {
    _dp.Play1();
    else if (_vegeta.contains(e.getPoint()) == _point) {
    _dp.Play2();
    else if (_gohan.contains(e.getPoint()) == _point) {
    _dp.Play3();
    else if (_trunks.contains(e.getPoint()) == _point) {
    _dp.Play4();
    else if (_piccolo.contains(e.getPoint()) == _point) {
    _dp.Play5();
    }

Maybe you are looking for

  • Time machine and network file server

    Hi, Is it possible to set up the time machine to a network file server which my macbook is able to see and use? Right now, time machine is limited to be used with a delicated external HD or another Mac... It would be convenient to share files between

  • Mapping of element contains errors

    Hi experts, I was doing a complex mapping for creating a Sales Order (Items, ItemsX, ...) Everything worked fine, I added 2 simple Types to the Data Type xsd file, redeployed and still worked. Now all of a sudden I can't seem to map anymore, with a p

  • Error while tranfer photos by Adobe Send

    Hi  While Adobe Send worked without any problems until last week, now every transfer aborts with message "One or more files could not be transferred - retry" I thought first some of my files were corrupted and wasted a lot of time - without success..

  • GL master default

    HI Gurus, I want to make the default in GL master for line item display and open item management. How can I do this? Waiting for your valuable response. Thanks & Regards, Anjana

  • Type tool anchor and pen tool problems CS4

    I have been working in In-design for my classes and everything is working fine. But recently I needed to do some work in Illustrator but when I opened the program up, some of my tools seems to be slightly bugged or something. The type tool will not m