This is an issue of implementing a c
function in a c++
environment.
National Instruments developed a NIDAQmx.h
header file with functions in c
. I've been successfully using their functions in a c++
class to control an acquisition device (cDAQ-9174). But one of the functions they provide is callback function that is triggered by an event on the device.
Here's the function in c
that I'd like to implement in c++
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData){
int32 error=0;
char errBuff[2048]={'\0'};
// Check to see if an error stopped the task.
DAQmxErrChk (status);
Error:
if( DAQmxFailed(error) ) {
DAQmxGetExtendedErrorInfo(errBuff,2048);
DAQmxClearTask(taskHandle);
printf("DAQmx Error: %s\n",errBuff);
}
return 0;
}
The event handler is registered to the device through the function:
DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL);
My question is: How do I implement a class member function that is capable of being triggered by this event? I imagine a function cast or some analogous way, but I don't know enough of c
and c++
to figure it out.
It would be important to implement this function so that my class knows when an acquisition task is over and release the device for some other instance to use.