scTDCLibrary
|
This is documentation for scTDC library API. scTDC library is used for access to Surface Concept GmbH Time to Digital Converter and Delay Line Detector devices.
Starting from the version 1.4.0 of scTDC library new abstraction was implemented to extract tdc and dld data from the device. The main mechanism for that is something which is called data pipe. Data pipes can be of different type and have different parameter. Every data pipe get pipe ident number when is opened with sc_pipe_open2() function. There could be as many pipes opened as application requires. After measure is started with sc_start_measure2() application should read the data from the data pipe with the sc_pipe_read2() function. When operation is finished data pipe should be closed with sc_pipe_close2().
Here is minimal example how things should be done:
To configure scTDC1 library application must supply inifile and firmware file (both supplied with the device). Inifile contains information about firmware file which will be used. That's why sc_tdc_init_inifile2() call takes only one parameter which is the name of the inifile. sc_tdc_init_inifile2() call returns positive integer number which serves as a device descriptor and must be user in all other calls related to the configured device. Negative returned value means error. There can be text description of the error obtained with the sc_get_err_msg() call.
sc_tdc_start_measure2() is used to start measure procedure. After the call device goes to the measurement state, extracts data from the device analizes it and transfers to the application through data pipes which must be configured previously. See Extracting Data section for more info how to operate with data pipes. In case of external start sc_tdc_start_measure2() call only transfer scTDC1 to the state of waiting for the start pulse on the device input. Currently external start feature must be switched in the inifile. Unfortunately there is no way to do that through scTDC API but this may be changed in future.
The main abstraction unit of the scTDC1 API which intend to be used for extracting processed (or raw) data from the library is a data pipe. Application can open as many data pipes as required for operation. All of them can have their own parameters, settings and types. The only limitation is the machine resources like memory and processor power. Due to of historical and optimisation reasons the processing happens in only one thread. This means that amount of time required to process one data unit (some number of tdc events) is linearly growing up with number of data pipes opened. The data processing mechanism may be changed in the future to be multithread.
Data pipe can be opened with sc_pipe_open2() call. Data can be extracted with sc_pipe_read2() call. sc_pipe_close2() call is used to close pipe and free resources used.
Here is a little example how data pipe for 2d images can be opened and operated (2d images available only when using dld device).
Due to of non-automatic memory handling in C programming language the question of allocation and deallocation memory is very important. Currently scTDC1 has two ways of memory treatment for data pipes. One is so called 'internal' memory allocation, when memory is allocated by scTDC1 and deallocated in the moment when next sc_pipe_read2(), sc_pipe_close2() or sc_tdc_deinit2() called. Second one - 'external' - when application supplies allocator callback function in data pipe parameters. In this case allocator callback function is called every time when data pipe processing algorithm needs memory for the data. Deallocation must be performed by the application.
Simple example for statistics pipe with external allocator:
Since version 1.3000.0 there was new data extraction mechanism implemented. The machanism uses set of callback functions provided by user to notify about one or another event or data delieved from the device.
Here is simple example:
Function which is marked as DEPRECATED belongs to the old API which has a number of problems which in principle cannot be resolved. It is still supported to make old applications work, but will be removed in the future. Please refrain from using it in new applications.