The TiePie engineering callback adapter is a universal callback to COM event adapter. It can be used in situations where a callback routine needs to be used in a framework that does not support callbacks, but does support COM events. An example of such a framework is Matlab.
Matlab does not support handing a pointer to a callback routine. According to the Mathworks website, there is no way to work with callback routines in Matlab:
"The ability to use shared library functions that have function pointer inputs is not available in MATLAB. There is no way to write a MATLAB function that is compatible with a C function pointer."
The solution provided by the callback adapter is to create a COM object that serves as a converter from callback to COM event. Because Matlab can respond to COM events by executing a script, this solution works well.
TiePie engineering oscilloscopes support continuous uninterrupted streaming measuring. Each time a block of data is captured, the application can collect the measured data, while the instrument keeps measuring. A callback function is used by the instrument DLL to let the application collect and process the measured data. As Matlab does not support callback functions, the callback adapter is required to convert the callback to a COM event. As Matlab can respond to COM events by executing a script, Matlab will be able to collect and process the data.
Use of the callback adapter is not limited to perform streaming measurements with a TiePie engineering instrument in Matlab. It can be used in any situation where a callback function is required and the programming environment does not support callback functions but does support COM events.
The zip file contains a TPCallback.DLL and two batch files for registering and unregistering the DLL. Place these files in a folder on your computer, the exact location is not important, but the files need to remain in that location after the installation. Then execute the TPCallback_Register.bat file in that folder. This will register the COM object 'TPCallback.TiePieCallbackAdapter' which is then ready for use.
In Matlab, this is achieved by:
hCallBackAdapter = actxserver('TPCallback.TiePieCallbackAdapter');
hCallBackAdapter.registerevent( {'OnCallbackCalled' 'CallbackScript'} );
calllib('DLL' , 'SetDataReadyCallback', hCallBackAdapter.CallbackPointer);
The COM event OnCallbackCalled will now be fired every time the callback routine of the adapter object is called.
To unregister and remove the callback adapter, browse to the folder where the callback adapter DLL is located and execute TPCallback_Unregister.bat in that folder. After the DLL has been unregistered, the folder and its contents may be removed.