Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous data collection using asynchronous calls in Visual C++.NET using NIDAQmx to a circular buffer

Any one has an example code in Visual C++.NET for acquiring multiple analog channels continuously using NIDAQmx asynchronous calls (with callback) and dumping the data into a circular buffer of known size so that it can be concurrenly accessed by a background program for processing?
0 Kudos
Message 1 of 9
(5,407 Views)
I did it in delphi so it is not too hard to translate. I build up a thread which has only one function: collecting data in end endless loop. If data read sample count is greter than zero it just sends a message to the main program's WndProc rutine. So i did it using a separate thread.
0 Kudos
Message 2 of 9
(5,369 Views)
Are you using managed C++ (C++ with .NET) or MFC? We have a .NET API that provides asynchronous continuous acquisition. If you are using plain C++ or if you don't have Measurement Studio, there is a C DAqmx API, but it does not have this capability builtin. If you have Measurement Studio 7.x, we provide a C++ (MFC) API with async acquisition with shipping examples and documentation as well.
Bilal Durrani
NI
0 Kudos
Message 3 of 9
(5,363 Views)
Hi Bilal,
I have Measurement studio 7.0. Can you give the link for C++.NET shipping examples and doc.
What is the advantage of using C++ MFC over C++.NET.
Thanks in advance
0 Kudos
Message 4 of 9
(5,349 Views)
Hi laboratory,

After installing DAQ support for Measurement Studio, you will be able to find examples from the following path:
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples

Thanks,
Lesley
0 Kudos
Message 5 of 9
(5,322 Views)
These are basically 2 different frameworks.

Managed C++ makes use of the new C++ extensions that were added by Microsoft that allows you to use the .NET framework libraries. Managed C++ makes use of garbage collection and other features provided by the .NET framework and allows you to create .NET DLLs (assemblies) and executables that use the Common Language Runtime (CLR).

Then there is unmanaged C++, which is basically C++ as it has always existed. This is using STL, Microsoft Foundation classes (MFC) and plain old C++ the way Bjarne S intended to create standard executables, DLLs and libraries. This does not use the .NET framework.

So the term C++ .NET can become vague, since Visual Studio 2003 .NET allows developing C++ applications with unmanaged and managed C++.

DAQmx includes a free .NET API as well as C API you can use to program the devices. If you have Measurement Studio 7.x, you will also get an MFC based C++ DAQmx API. If you are not using the .NET framework, then you would probably need to use the C or the MFC based C++ DAQmx API.

LYu already posted the path to where you might find the .NET examples. They use C# and VB.NET, but they give you an idea of how the API is set up.
For the C examples, look under C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.
If you have Measurement Studio 7.x, then you can find the unmanaged C++ DAQmx examples under C:\Program Files\National Instruments\MeasurementStudio70\VCNET\Examples\DAQmx

The documentation for the MFC C++ API is integrated into the VIsual Studio Help.

You can fins the DAQmx C reference by going to Start >> Programs >> National Instruments >> NI-DAQ >> NI-DAQmx C Reference Help.

We do not have any managed C++ examples.

Hope this helps. Let me know if I missed anything.
Bilal Durrani
NI
0 Kudos
Message 6 of 9
(5,308 Views)
Hi Bilal,
You gave the best explanation for the confusion I had so far. The word C++ has been used in NI documents so vaguely, it was difficult to know whether they are talking about managed or unmanaged C++. You explained it very well bringing out the differences. Even though the MFC based C++ DAQmx API in Measurement studio 7.X is basically unmanaged, Can it be used with managed code? If so, how do you mix it?
Are you planning to add any managed C++ examples?
0 Kudos
Message 7 of 9
(5,295 Views)
Things became weird since Microsoft decided to add .NET to the name of their development enviornment. I believe they are changing that for their next version. People initally thought that Microsoft was going to get rid of MFC since the IDE now said .NET. We try to explicit in our documentation by using using the term unmanaged vs. managed. I agree this can get confusing expecially if you're trying to figure this out for the first time. If there were any topics that you felt were confusing and needed clarification, let me know.

You cannot mix and match the .NET and C++ APIs for DAQmx. It has to be either one or the other. You can use the .NET API in an MFC application ( managed C++ mixed mode magic), but it gets complicated really fast. Things can get really hairy if you are not aware of the voodoo that the C++ compiler is doing to enabled mixed mode interaction. By mixed mode, I mean the ability to have managed and unmanaged code coexist in the same library. You can do this with C++.

So basically, use the MFC DAQmx API with an MFC app, and the .NET DAQmx API with a .NET app to keep things simple.

Check out this post for where we stand with managed C++ support for our .NET libraries.

Hope this helps. If you do have questions while developing your app, feel free to post your questions on the forum.
Bilal Durrani
NI
0 Kudos
Message 8 of 9
(5,279 Views)

Hi,

 

I have a question here.

So if I want to use the MFC DAQmx API with an MFC app, I must have Measurement Studio 7.x?

Can the app run in Microsoft Visual C++ 6.0?

 

Thank you.

0 Kudos
Message 9 of 9
(3,976 Views)