Where to put data processing routine when acquiring data using DAQmx

I have a program that is aquiring data using the DAQmx Acquire N Samples mechanism with automatic reset and a data handler callback routine. DAQmx acquires N samples (usually 1024) from the board, calls the handler to do something with it, and then resets to get the next batch of data. The program acquires a number of lines of data, say 512 lines of N points each, with one callback call per line. Triggering is done by a hardware trigger at the start of each line of data. So far so good.
The issue is that the time that it can spend in the callback is limited, or else the callback is not finished when the next batch of data is ready to be transferd from the DAQmx buffers and processed. There is a substantial amount of analysis to be done after the entire frame has been acquired, and it ends up taking far longer than the time between lines; so where to put the processing? The data acquisition is started from a control callback callback that exits back to the idle loop after it starts the data acquisition process, so there is no code waiting to execute, to return to, when the data acquisition is finished.
I could try to put the data analysis routine into an idle-time routine and trigger it with a semaphore, or I could put it into a timer control callback with, say, a 10 millisecond repetition rate and poll a flag, setting the flag when all of the data has been acquired. Any suggestions would be appreciated.

I would recommend using Thread Safe Queues. Your acquisition callback can place items in the TSQ and then you can process the data in a separate thread. TSQs are nice because they allow you to install a callback function to run for certain events. Most importantly, you can install a callback for the Items in Queue or Queue Size Changed event which will run the callback if a certain number of items are in the queue. This lets you take advantage of multithreading in a simple and safe way using a standard Producer/Consumer architecture. However, you may still run into problems with this architecture if your acquisition thread is running much faster than the consumer thread. You could eventually overflow the queue. In that case, your only options are to either get a faster system, slow down the acquisition or do the data handling post process.
National Instruments
Product Support Engineer

Similar Messages

  • Where to put page redirect code when using htp.prn

    Apex 4.0 oracle 11g.
    The user starts on page 7, chooses rows from a list and clicks a Run button which redirects them to page 10 which has a process (on load before header) using htp.prn to create a text file which the user then can save. The end of this process has apex_application.g_unrecoverable_error := true; because if it doesn't have this, the HTML gets put into the text file too.
    Anyway, when the user is done saving this text file, to all appearances they are still on page 7 (since page 10 doesn't really load, just runs that process) but I want them to go to page 14 after saving, not stay on page 7. I can't figure out where to put the redirect. The branching on page 7 doesn't seem to get activated after they hit the save button of the popup file save window, page 10 never loads for a branch on that page to work and I tried to put
    htp.init;
    owa_util.redirect_url('f?p=&APP_ID.:14:&APP_SESSION.');
    after the htp.prn call in but then the popup file download window doesn't come up at all and the user is immediately redirected to page 14.
    This is the process - I've tried the redirect inside its own begin end; and it didn't make any difference. If I put it in a separate process, it never gets run because as soon as the htp.prn is done, all processing stops. Any ideas on how I can get this file created and then redirect user to page 14? Thanks!
    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="this_file_add.txt"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Loop through all rows in CLIENT_TABLE
    for x in (select HEADER_TRANS_TYPE
    , HEADER_FILLER
    , TRANS_TYPE_CD
    , SOURCE_DEPT_NBR
    , DEST_DEPT_NBR
    , ENV_TYPE
    , FILE_SEQ_NBR
    from TEMP_CRA_EXTRACT
    loop
    -- Print out rows
    htp.prn(x.HEADER_TRANS_TYPE|| x.SOURCE_DEPT_NBR|| x.DEST_DEPT_NBR|| x.TRANS_DATE || x.ENV_TYPE || lpad(x.FILE_SEQ_NBR, 4, '0') || rpad(x.HEADER_FILLER, 48) || x.TRANS_TYPE_CD || rpad(x.XREF_NBR, 12) || chr(13) || chr(10) );
    end loop;
    -- Send an error code so that the rest of the HTML does not render
    apex_application.g_unrecoverable_error := true;
    htp.init;
    owa_util.redirect_url('f?p=&APP_ID.:14:&APP_SESSION.');
    end;

    I would recommend using Thread Safe Queues. Your acquisition callback can place items in the TSQ and then you can process the data in a separate thread. TSQs are nice because they allow you to install a callback function to run for certain events. Most importantly, you can install a callback for the Items in Queue or Queue Size Changed event which will run the callback if a certain number of items are in the queue. This lets you take advantage of multithreading in a simple and safe way using a standard Producer/Consumer architecture. However, you may still run into problems with this architecture if your acquisition thread is running much faster than the consumer thread. You could eventually overflow the queue. In that case, your only options are to either get a faster system, slow down the acquisition or do the data handling post process.
    National Instruments
    Product Support Engineer

  • Where to put JAAS classfiles (loginmodules) when using it from a web app

    Hi,
    I am using JAAS authentication from a web application, the problem is that the login modules that I use, and all the classes that the LoginModule uses are not loaded from the WEB-INF/classes or WEB_INF/lib folder. I have to put them on the jdk/jre/lib/ext. The problem is that the classes I put there collide with other applications that use the same installed JDK.
    I have developed it using jdk1.3.1 and JAAS 1.0.
    Is there a way to put specify where login module classes should be loaded that does not interfere with other applications (that is, I do not want to put any class on the jdk/jre/lib/ext folder).
    Cheers

    Unfortunately, the only alternatives are to put all resources required by JAAS in jre/jre/lib/ext OR on the system classpath when the JVM is started.
    This is apparently due to a bug in JAAS. The implementers of JAAS have the LoginContext written so that it loads resources only from the system classpath. Unless this was, for some reason intentional. I don't know what the plans are for JAAS going forward with respect to this.
    Has it been fixed in J2SE 1.4?
    I'll have you know this wreaks havoc with attempting to have your LoginModule use an EJBs to authenticate a user and add Principals to the Subject.

  • Where to put custom .jar-files in order to use them in scripting QPAC?

    Hi,
    For testing purposes, I wrote a simple class and put it in a .jar-file to use in scripting QPAC. Unfortunately, I get the following error message in JBOSS:
    Class: FooBar not found in namespace
    Where do I have to put custom library (jar-)files in order for JBOSS to find them? I already tried
    [...]\jboss\lib as well as
    [...]\jboss\server\all\lib.
    Regards,
    Steve

    Hi Steve
    You need to put them in two places:
    1. In the server classpath, so that they can be found at runtime. jboss\server\all\lib should work, or you can even drop them into the server/all/deploy directory. I think if you put them in the lib directory, you need to restart Jboss, whereas if you put them in the deploy directory, they should be dynamically picked up.
    2. For testing purposes, the extra jars need to be in the classpath of the Workflow Designer. Please download our SQLPlus QPAC from:
    http://www.avoka.com/avoka/qpac_library.shtml
    It includes a document that describes a technique for adding extra jars to the classpath.
    Regards,
    Howard
    http://www.avoka.com

  • Where to put data validation & DB access in MVC designed app ?

    Hi,
    I write a stand alone app, because the user interface might required lots of changes in the future, I want to apply the MVC paradigm in the user interface design to improve maintainability.
    Where should I put the routine to perform data validation and read/write database ?
    Any advice would be greatly appreciated.
    Setya

    Like the tutorial says, you mustn't perform blocking or non-running operations in the GUI event thread.

  • SMP 3.0 Agentry: Where to put data table files?

    Hi,
    we are using several file system data tables in our application which load their data from a file named "datatables.txt".
    In SMP 2.3 this file was placed inside the "tables" directory of the Agentry server. In SMP 3.0 we tried the com.sap.mobile.platform.server.agentry.application directory without success. What ist the right place for that file now?
    Thanks
    Christoph

    Christoph,
    Yes, I would recommend logging a support ticket related to this so it can be reviewed and hopefully migrated to the new application specific directory.
    --Bill

  • Integration Process/ccBPM - When to be used

    Hi All,
    I have a scenario where i need to trigger the webservices in a third party java based system based on a value provided by SAP Workflow. Here two different web services are involved which needs to be triggred based on the response from the user.
    Below are the steps that are involved in the entire process:
    1. User request for an order and if material quantity is found, service 1 is triggered.
    2. If the material quantity is not found, Service 2 is trigerred providing user with alternate options.
    3. Now based on user response, if he agrees for alternate option, service 1 is trigerred.
    Can any body explain how to do this in XI or perticularly in ccBPM.
    Please let me know if you need further information
    Help will be appriciated.
    Thanks and best regards,
    Kulwant

    Hi Kulwant,
    Though I had mentioned some steps earlier also, i am putting them again here for you:
    Following are the steps for Integration Repository:
    1) You would need an outbound proxy program to send data from SAP workflow. I am not proficient in SAP workflow but i know you can write some code in the workflow steps to send data to SAP XI, you get examples of writing an outbound proxy program in SDN.
    2) Now your outbound proxy would trigger this particular scenario. It will bring input parameters for first java based webservice in XI.
    3) You need to create data type, message type and outbound message interface for your SAP workflow structure. you need not create data type and message type for Java based web service as you would be directly importing it's wsdl and using it as your inbound message interface in message and interface mappings directly.
    4) If the third party webservice is a synchronous one, then while creating the message mappings you need to create two message mappings for the 1st java based webservice, i.e. one for request and 1 for response, you would also need to create a response structure to create the mapping for 1st java based webservice's response or if you want to directly pass the output of 1st webservice as an input to the 2nd java based webservice, you can also do that.
    5) Create a response mapping for the response of 2nd webservice in a similar fashion.
    Confuguration / Integration Directory:
    1) For sender side you do not need any communication channel. For receiver side you would need one as I mentioned earlier. To create a communication channel, you need to first create or import (if already created) a business system or a business service (you can read about these in help.sap.com, ask me if you need the link). I would suggest a business system as web service provider is a third party. How to do it:
    ID--><your configuration scenario> --> Service without Party --> Business Service / Business system --> right click to create or assign.
    Note: looking @ yesterdays posts, i believe it's fine for you to create just a business service only.
    2) When you are done with this, you get a communication channel option created inside you business system or business service. Right click to create a communication channel. Give a name to it and press F4 to select the adapter type as SOAP. it would be a receiver. Read help.sap.com for more info on it.
    Note: you would need two receiver SOAP communication channels for executing the 2 java based web services.
    3) Rest of the mostly needed parameters i have already mentioned in my earlier posts for configuring the communication channel.
    Hint: the target URL needed to configure the communication channel is usually there in <SOAP:action> tag in the wsdls of the respective web services.
    4) Next create a Receiver determination --> Interface determination --> Sender Agreement --> Receiver Agreement
    7) For receiver determination, you need to enter a business service / business system and the sender message interface. If you have chosen your own service then you need to register your message interface in the service. double click on the service name to do it. there are options to register inbound / outbound messages.
    If you can use a conditional receiver determination to determine the user response and call the relevant web service based on that. At the 'edit receiver determination' screen there is a 'configured receivers' tab, where in condition field you can press F4. When you pess F4, a new screen opens, in left operand field, again press F4, a new screen would again open up, select 'Xpath' and there select the field in your sender (structure coming from workflow) structure, the field which contain the user choices (say 1 or 2 as mentioned by you).
    Similarly, in the same receiver determination based on the condition, you can call either webservice 1 or 2.
    8) For interface determination, you need to perform same steps as step no 7 also you need to enter your receiver service or business system.
    9) In sender and receiver agreements you mention sender and receiver communication channels. Well in your case you need not make any sender agreement as you sending data from R/3 to XI directly.
    if you configure these object completly, i believe you scenario should run.
    In case of more queries, feel free to ask,
    Thanks,
    Varun

  • Should Apple TV be put into standby mode when not in use?

    Anyone,
    When I am done watching Apple TV, should I put it into standby mode or leave it on? Just want to take of my new favorite toy!!!!

    I tend to leave them on all the time - standby mode isn't particularly low power as lots of things are still active.

  • Acquiring signal using DAQmx 6221

    I'm new to using DAQ. I need some pointers on how to go about the following
    issue. I want to acquire a sine wave through DAQmx (PCI 6221). I need to
    acquire the signal at a particular rate and store it as a binary and ASCII
    file. Also I want to know how to output a signal through DAQmx. Could you
    please give some pointers and example VIs if any?
    Thanks,
    Sukanya

    Go to Help>Find Examples. Then expand Hardware Input and Output>DAQmx. Also look at Getting Started With DAQmx.

  • Where to put ASE files

    Once I download the ase files I can't quite figure out where
    to put them so that when I'm using Photoshop or Illustrator or any
    Adobe application they will show up as option for me to select from
    in the swatches palette. Any advice would be appreciated.
    Thanks!

    Thanks for the tip. It was helpful. By doing that I realized
    that I could store the .ase files in the same place Adobe
    Photoshop, Illustrator, In Design, and Go Live currently store the
    swatches.
    I have CS2, and this is where I found the current storage of
    swatches.
    C Drive > Program Files > Adobe > Adobe Photoshop
    CS2 (or Illustrator, In Design, Go Live) > Presets > Color
    Swatches/Swatch Library/Swatches (depending on the app)
    Then I tested each out in that particular application and
    they worked beautifully. The only thing that stinks is that you
    have to put the .ase file in each Swatch folder for each one of the
    applications so in my case that was 4 times. I guess you could keep
    them in one central place and then access them from all
    applications.

  • My computer screen keeps going blank and then going back to the box where I put my password in to start my comp. Why is this happening?

    My computer (Macbook) was working fine this am. I left it for an hour and then came back and the screen was black (always does that as the screensaver hardly ever works). I moved the mouse to wake it up and everything was normal. I went to adjust the volume and the screen went blank and the main page with the box where I put my password in when I first start my comp appeared. I put my password in and everything was normal again. I opened a window in Safari and before it loaded completely the same thing happened, the screen went blank and went back to the password box. Does anyone know why this is happening? I don't have an external hard drive or any blank flash drives so I can't back anything up right now and am afraid I'm going to lose everything. Thank you

    Sounds like hardware failure, called boot loop. Call Apple and or go on apple.com and make Genius Bar appointment to have your iphone reviewed by a Tech. Provided you iphone shows no physical or liquid damage they will take care of you, or if you have Apple Care Plus
    Genius Bar Rerservation :  http://www.apple.com/retail/geniusbar/

  • Urggggent...where to put xmlparserv2.jar

    hi guys i want to use DOM and i dont know where to put this file so when i import it JDev recognize it;

    Go to your project's settings dialog and look under the libraries item. You'll be able to define a new library there (which uses your jar file) that your project can use.

  • How to make a external HD (FireWire or USB) spin down when no in use?

    I have a MM and want to make sure that the external HD spins down if not being used.
    Would this automatically happen if I tick the box 'Put HD to sleep when not in use' in the control panel? Or is there an other solution to make sure it does so? I have not bought a disk as of now, but would be looking at a 2.5 (Samsung HM500LI 500 GB (SpinPoint M6)) in a FireWire housing.
    Thanks

    I really have no idea because I never sleep disks. However, that's controlled by the setting in the /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist file. The default is ten minutes if you sleep disks. Experiment with various settings by issuing this command in the Terminal.app, until you get it the way you want it:
    *sudo pmset -a disksleep XX*
    where XX is the new time in minutes.

  • SUDDEN SPIKE IN DATA USE?  ACCURACY OF DATA OVERAGE ALERTS?

    Our data usage over the past 6 months averaged 2.25 GB  Top usage during that period was 2.99 GB in May
    Since I had been paying for 6 GB and never using it, I switched to 4 GB in May and signed up for Data Usage Overage Alerts.
    Then...all "heck" seemed to break loose???
    May 23 Received data alert via text: Have Used 75% of 3 GB--Added 1 GB
    May 27 Received data alert via text: Have Used 90% of 4 GB
    May 29 Received data alert via text: Have Used 100% of 4 GB-Added 2 GB
    June 1  Received data alert via text: Have Used 75% of 6 GB
    June 7  Received data alert via text: Have Used 90% of 6 GB
    OUR BILLING CYCLE ENDED JUNE 9
    June 11 Received data alert via text: Have Used 100% of 6 GB (???)
    Stunned that between the May 10 - June 9 billing cycle my reported data usage suddenly went over 6 GB for the first time ever, and not doing anything differently at all, I called Verizon Customer Service...
    The rep asked if I had been doing something differently with my phone (apps, photos, etc)
    I replied that my usage had not changed in any way...
    To which she responded that she was unable to track where/why my data use was suddenly so high...???  She had "No way of knowing"
    NEED HELP FROM VERIZON AND/OR COMMUNITY: 
    1.     ARE VERIZON DATA ALERTS UNRELIABLE?
    2.     HOW/WHY WOULD DATA USAGE INCREASE SO DRAMATICALLY WITH NO WAY FOR CUSTOMER TO CHECK/VERIFY?
    MANY THANKS...

    Like radar guns used by local police departments, I firmly believe that without some sort of independent oversight like cable companies use to check the meters Verizon wireless can tell you anything and you the consumer gets hit with high data use.
    My best solution for you is to reset the data counter on the phone starting with the first day of your billing cycle. Then check your online data used and see if they match.
    I also recommend you contact the FCC or even keep taking them to small claims or a superior court to have them produce records of data meter accuracy. At present no known outside concern can monitor what Verizon is claiming you are using.
    Get a good lawyer and take them to court.
    Good Luck

  • How do I troubleshoot installation/distribution of a LabVIEW .exe which processes data using Matlab when it works on some computers but not others?

    I've been given the unenviable task of troubleshooting and installing/distributing software written by a former co-worker. I've modified the LabVIEW code and built an .exe file. I've successfully installed the Labview .exe file on several computers, but it won't work on some others. What's more baffling is that I installed it successfully on one computer, uninstalled it, and tried reinstalling it with no success. In fact, it's a new error (Dr. Watson for Windows NT application error). It doesn't help that I have different versions of LabVIEW and Matlab on the target computers. Some have LabVIEW 5.1, some
    have 5.0, and some don't have it at all. Some have Matlab 5.2, some have 5.3 (R11) and some have 6.0 (R12). It's also not clear to me where the Matlab m files should be located. I'm not sure if it's a LabVIEW Runtime Engine problem, or if it's a Matlab problem. I've also wondered how LabVIEW and Matlab talk to each other. When LabVIEW calls Matlab, it seems that Matlab is running in the background. In other words, clicking on the Matlab Command Window and typing "whos" or any other command/variable doesn't work.

    Jay del Rosario wrote:
    >
    > How do I troubleshoot installation/distribution of a LabVIEW .exe
    > which processes data using Matlab when it works on some computers but
    > not others?
    Poke around zone.ni.com and
    http://digital.natinst.com/public.nsf/$$Search/ .
    Good luck, Mark

Maybe you are looking for