11-19-2007 06:43 AM
11-20-2007 05:53 AM
Hi EDF
Can you pls give us a step by step guide of what you are trying to do? I will try to replicate the problem.
Thank you,
KostasB
Applications Engineering
National Instruments
11-20-2007 09:18 AM
11-20-2007 02:33 PM - edited 11-20-2007 02:34 PM
Hi edf,
As far as the missing DAQ code snippets, this was fixed in DAQmx 8.6 which is released.
With regards to your main question, based on your comments about using a while loop for your data acquisition, you need to be doing continuous sampling instead of finite sampling. Since you are using the DAQ assistant, this can be easily changed. Open up the DAQ Assistant by double-clicking on your xxx.mxb file located in the Solution Explorer. Then modify the Acquisition Mode item to be Continuous Samples.
When you use continuous sampling with the DAQ component, our DAQ component is firing off a worker thread to do the actual data acquisition. This is perfect in your case since you want to free up your UI and make it more responsive. We even go a step further in that case and marshal the data back to the UI thread so you can plot the data to your UI components.
Now you didn't mention if you used our DAQ Component to generate a UI for you. If you are just starting out, the resultant code should look something like the attached "Generated Code.jpg" snapshot. If you notice, the code is calling StartRead method which starts the continuous input acquisition. The resultant acquisition will be done on a worker thread. Then we hook up to the DataReady event and grab the data when it’s ready via the GetData method. Now we are back on the main UI thread and you notice we can plot the data to the graph. This is where you can do your own plotting to your graphs or spawn a new thread to do some analysis or data logging. This is the recommended approach.
Now if you already have some code written and don't want to generate the UI, you basically need to re-write what our UI code generated with respect to starting the reads and hooking up to the appropriate events. For example, you would need the StartRead and StopRead calls and you would need to hook up to the DataReady event. In your event handler for the DataReady event, you could grab the data, and do whatever you want. See the snapshot, "Manual Typing.jpg".
You can learn how threading, reading and writing with DAQ works in the NI Measurement Studio Help under the topics "Using the Measurement Studio DAQmx .NET Library". That has sections on reading and writing as well as a section entitled "Events, Callbacks, and Thread Safety in Measurement Studio .NET Class Libraries"
Hope this helps!
Best Regards,
11-23-2007 06:00 AM