Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Register Call BAck function in Visual C++

How do I define the Call back function from the RegisterEveryNSamplesEvent as a data memebr of a class so I don't get compile errors in Visual C++ (2005) MDI- MFC..... The function has a prototype like this: int32 CVICALLBACK Callback (TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData); .......... I can declare it on top of .CPP file as a static function sort of the NI sample examples, but then, I would have no access to the data members of the class like Buffers, chs...etc.... There must be something I am missing, how are we supposed to process the data and pass data back and forth from and to this Call back function where we are supposed to read the data from the NI buffers since Buffers are ready to be read...............

 

Can someone please clarify this to me?

 

Thanks

0 Kudos
Message 1 of 4
(8,848 Views)

Hi,

 

Do you have Measurement Studio on your machine as well as DAQmx?  If you do, a great place for you to get started would be with the shipping examples that are located at <NI-DAQ>\Examples\MStudioVC2003 or MStudioVC2005 .  These are the MFC DAQmx examples. 

 

Examples of how to register for callbacks like the RegisterEveryNSamplesEvent are located in the DAQmx ANSIC directory at <NI-DAQ>\Examples\DAQmx ANSI C which install with DAQmx.  I am unsure if this is the approach you want to take however, as the method for registering for callbacks in C may not be applicable in MFC C++.

Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 2 of 4
(8,825 Views)

Hi,

if its not the way to go, and I am having hard time getting in to work in MFC, what is the way to go...All I need is something to tell me Buffer is complete and ready to be read. I would have thought moving from traditional to NIDAQmx will make things easier, not more complicated, and they would have kept a flag or something like that.

0 Kudos
Message 3 of 4
(8,815 Views)

Thread continued here

 

NickB

National Instruments 

0 Kudos
Message 4 of 4
(8,781 Views)